View | Details | Raw Unified | Return to bug 20443
Collapse All | Expand All

(-)a/C4/Members.pm (-1 lines)
Lines 33-39 use C4::Reserves; Link Here
33
use C4::Accounts;
33
use C4::Accounts;
34
use C4::Biblio;
34
use C4::Biblio;
35
use C4::Letters;
35
use C4::Letters;
36
use C4::Members::Attributes qw(SearchIdMatchingAttribute);
37
use C4::NewsChannels; #get slip news
36
use C4::NewsChannels; #get slip news
38
use DateTime;
37
use DateTime;
39
use Koha::Database;
38
use Koha::Database;
(-)a/C4/Members/Attributes.pm (-14 / +1 lines)
Lines 32-38 BEGIN { Link Here
32
    @ISA = qw(Exporter);
32
    @ISA = qw(Exporter);
33
    @EXPORT_OK = qw(
33
    @EXPORT_OK = qw(
34
                    extended_attributes_code_value_arrayref extended_attributes_merge
34
                    extended_attributes_code_value_arrayref extended_attributes_merge
35
                    SearchIdMatchingAttribute);
35
                    );
36
    %EXPORT_TAGS = ( all => \@EXPORT_OK );
36
    %EXPORT_TAGS = ( all => \@EXPORT_OK );
37
}
37
}
38
38
Lines 46-64 C4::Members::Attributes - manage extend patron attributes Link Here
46
46
47
=head1 FUNCTIONS
47
=head1 FUNCTIONS
48
48
49
=head2 SearchIdMatchingAttribute
50
51
  my $matching_borrowernumbers = C4::Members::Attributes::SearchIdMatchingAttribute($filter);
52
53
=cut
54
use Koha::Patrons;
55
sub SearchIdMatchingAttribute{
56
    my $filter = shift;
57
58
    my @borrowernumbers = Koha::Patrons->filter_by_attribute_value($filter)->get_column('borrowernumber');
59
    return \@borrowernumbers;
60
}
61
62
=head2 extended_attributes_code_value_arrayref 
49
=head2 extended_attributes_code_value_arrayref 
63
50
64
   my $patron_attributes = "homeroom:1150605,grade:01,extradata:foobar";
51
   my $patron_attributes = "homeroom:1150605,grade:01,extradata:foobar";
(-)a/C4/Utils/DataTables/Members.pm (-3 / +2 lines)
Lines 4-10 use Modern::Perl; Link Here
4
use C4::Context;
4
use C4::Context;
5
use C4::Utils::DataTables;
5
use C4::Utils::DataTables;
6
use Koha::DateUtils;
6
use Koha::DateUtils;
7
use C4::Members::Attributes qw(SearchIdMatchingAttribute );
8
7
9
sub search {
8
sub search {
10
    my ( $params ) = @_;
9
    my ( $params ) = @_;
Lines 131-139 sub search { Link Here
131
130
132
131
133
        if ( $searchfieldstype eq 'standard' and C4::Context->preference('ExtendedPatronAttributes') and $searchmember ) {
132
        if ( $searchfieldstype eq 'standard' and C4::Context->preference('ExtendedPatronAttributes') and $searchmember ) {
134
            my $matching_borrowernumbers = C4::Members::Attributes::SearchIdMatchingAttribute($searchmember);
133
            my @matching_borrowernumbers = Koha::Patrons->filter_by_attribute_value($searchmember)->get_column('borrowernumber');
135
134
136
            for my $borrowernumber ( @$matching_borrowernumbers ) {
135
            for my $borrowernumber ( @matching_borrowernumbers ) {
137
                push @where_strs_or, "borrowers.borrowernumber = ?";
136
                push @where_strs_or, "borrowers.borrowernumber = ?";
138
                push @where_args, $borrowernumber;
137
                push @where_args, $borrowernumber;
139
            }
138
            }
(-)a/t/db_dependent/Members/Attributes.t (-9 lines)
Lines 182-195 throws_ok { # Creating a new one, but already exists! Link Here
182
} 'Koha::Exceptions::Patron::Attribute::UniqueIDConstraint';
182
} 'Koha::Exceptions::Patron::Attribute::UniqueIDConstraint';
183
183
184
184
185
my $borrower_numbers = C4::Members::Attributes::SearchIdMatchingAttribute('attribute1');
186
is( @$borrower_numbers, 0, 'SearchIdMatchingAttribute searchs only in attributes with staff_searchable=1' );
187
for my $attr( split(' ', $attributes->[1]->{attribute}) ) {
188
    $borrower_numbers = C4::Members::Attributes::SearchIdMatchingAttribute($attr);
189
    is( $borrower_numbers->[0], $borrowernumber, 'SearchIdMatchingAttribute returns the borrower numbers matching' );
190
}
191
192
193
$patron->get_extended_attribute($attribute->{code})->delete;
185
$patron->get_extended_attribute($attribute->{code})->delete;
194
$borrower_attributes = $patron->extended_attributes;
186
$borrower_attributes = $patron->extended_attributes;
195
is( $borrower_attributes->count, 2, 'delete attribute by code' );
187
is( $borrower_attributes->count, 2, 'delete attribute by code' );
196
- 

Return to bug 20443