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

(-)a/installer/data/mysql/atomicupdate/bug_39229_add_syspref.pl (+19 lines)
Line 0 Link Here
1
use Modern::Perl;
2
use Koha::Installer::Output qw(say_warning say_success say_info);
3
4
return {
5
    bug_number  => "39229",
6
    description => "Search unique extended attributes on patron quicksearch",
7
    up          => sub {
8
        my ($args) = @_;
9
        my ( $dbh, $out ) = @$args{qw(dbh out)};
10
11
        # Do you stuffs here
12
        $dbh->do(
13
            q{ INSERT IGNORE INTO `systempreferences`(`variable`, `value`, `options`, `explanation`, `type`) VALUES ('UniqueExtendedAttributesQuickSearch', '0', NULL, 'Enable first running a search against all unique attributes when using the patron search bar, if a patron is found redirect to that patron without performing a full search. This can significantly improve performance if unique attributes are commonly searached for and the number of patrons is sufficiently large.', 'YesNo') }
14
        );
15
16
        # sysprefs
17
        say $out "Added new system preference 'UniqueExtendedAttributesQuickSearch'";
18
    },
19
};
(-)a/installer/data/mysql/mandatory/sysprefs.sql (+1 lines)
Lines 818-823 INSERT INTO systempreferences ( `variable`, `value`, `options`, `explanation`, ` Link Here
818
('UNIMARCAuthorityField100','afrey50      ba0',NULL,'Define the contents of UNIMARC authority control field 100 position 08-35','Textarea'),
818
('UNIMARCAuthorityField100','afrey50      ba0',NULL,'Define the contents of UNIMARC authority control field 100 position 08-35','Textarea'),
819
('UNIMARCAuthorsFacetsSeparator',', ',NULL,'UNIMARC authors facets separator','short'),
819
('UNIMARCAuthorsFacetsSeparator',', ',NULL,'UNIMARC authors facets separator','short'),
820
('UNIMARCField100Language','fre',NULL,'UNIMARC field 100 default language','short'),
820
('UNIMARCField100Language','fre',NULL,'UNIMARC field 100 default language','short'),
821
('UniqueExtendedAttributesQuickSearch', '0', NULL, 'Enable first running a search against all unique attributes when using the patron search bar, if a patron is found redirect to that patron without performing a full search. This can significantly improve performance if unique attributes are commonly searached for and the number of patrons is sufficiently large.', 'YesNo'),
821
('UniqueItemFields','barcode','','Pipe-separated list of fields that should be unique (used in acquisition module for item creation). Fields must be valid SQL column names of items table','Free'),
822
('UniqueItemFields','barcode','','Pipe-separated list of fields that should be unique (used in acquisition module for item creation). Fields must be valid SQL column names of items table','Free'),
822
('UnseenRenewals','0','','Allow renewals to be recorded as "unseen" by the library, and count against the patrons unseen renewals limit.','YesNo'),
823
('UnseenRenewals','0','','Allow renewals to be recorded as "unseen" by the library, and count against the patrons unseen renewals limit.','YesNo'),
823
('UnsubscribeReflectionDelay','',NULL,'Delay for locking unsubscribers', 'Integer'),
824
('UnsubscribeReflectionDelay','',NULL,'Delay for locking unsubscribers', 'Integer'),
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/patrons.pref (+7 lines)
Lines 86-91 Patrons: Link Here
86
               1: Do
86
               1: Do
87
               0: "Don't"
87
               0: "Don't"
88
         - enable the ability to upload and attach arbitrary files to a borrower record.
88
         - enable the ability to upload and attach arbitrary files to a borrower record.
89
     -
90
         - pref: UniqueExtendedAttributesQuickSearch
91
           choices:
92
               1: Enable
93
               0: "Don't enable"
94
         - to first run a search against all unique attributes when using the patron search bar, if a patron is found redirect to that patron without performing a full search.
95
         - This can significantly improve performance if unique attributes are commonly searached for and the number of patrons is sufficiently large.
89
     -
96
     -
90
         - pref: useDischarge
97
         - pref: useDischarge
91
           choices:
98
           choices:
(-)a/members/member.pl (-9 / +33 lines)
Lines 52-66 if ( $quicksearch and $searchmember && !$circsearch ) { Link Here
52
        my $userenv = C4::Context->userenv;
52
        my $userenv = C4::Context->userenv;
53
        $branchcode = $userenv->{'branch'};
53
        $branchcode = $userenv->{'branch'};
54
    }
54
    }
55
    my $maybe_redirect = sub {
56
        my ($patron) = @_;
57
        if (
58
            $patron
59
            and (  ( $branchcode and $patron->branchcode eq $branchcode )
60
                or ( not $branchcode ) )
61
            )
62
        {
63
            print $input->redirect( "/cgi-bin/koha/members/moremember.pl?borrowernumber=" . $patron->borrowernumber );
64
            exit;
65
        }
66
    };
67
55
    my $patron = Koha::Patrons->find( { cardnumber => $searchmember } );
68
    my $patron = Koha::Patrons->find( { cardnumber => $searchmember } );
56
    if (
69
    $maybe_redirect->($patron) if ($patron);
57
        $patron
70
58
        and (  ( $branchcode and $patron->branchcode eq $branchcode )
71
    # Search all unique patron attributes
59
            or ( not $branchcode ) )
72
    my @unique_types = Koha::Patron::Attribute::Types->search( { 'unique_id' => 1 } )->as_list;
60
        )
73
    my @attribute_conditions;
61
    {
74
    for my $type (@unique_types) {
62
        print $input->redirect( "/cgi-bin/koha/members/moremember.pl?borrowernumber=" . $patron->borrowernumber );
75
        push @attribute_conditions, [
63
        exit;
76
            {
77
                "extended_attributes.code"      => $type->code,
78
                "extended_attributes.attribute" => $searchmember
79
            }
80
        ];
81
    }
82
83
    if (@attribute_conditions) {
84
        my @patrons = Koha::Patrons->search( \@attribute_conditions, { prefetch => ['extended_attributes'] } )->as_list;
85
86
        # The only case where could be more than one is when multiple unique attribute has the same value for different patrons
87
        # which should be unlikely. If that is the case we should perform a full search.
88
        $maybe_redirect->( $patrons[0] ) if ( @patrons == 1 );
64
    }
89
    }
65
}
90
}
66
91
67
- 

Return to bug 39229