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

(-)a/Koha/Template/Plugin/ExtendedAttributeTypes.pm (+71 lines)
Line 0 Link Here
1
package Koha::Template::Plugin::ExtendedAttributeTypes;
2
3
# Copyright ByWater Solutions 2023
4
5
# This file is part of Koha.
6
#
7
# Koha is free software; you can redistribute it and/or modify it
8
# under the terms of the GNU General Public License as published by
9
# the Free Software Foundation; either version 3 of the License, or
10
# (at your option) any later version.
11
#
12
# Koha is distributed in the hope that it will be useful, but
13
# WITHOUT ANY WARRANTY; without even the implied warranty of
14
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
# GNU General Public License for more details.
16
#
17
# You should have received a copy of the GNU General Public License
18
# along with Koha; if not, see <http://www.gnu.org/licenses>.
19
20
use Modern::Perl;
21
22
use Template::Plugin;
23
use base qw( Template::Plugin );
24
25
use C4::Koha;
26
use C4::Context;
27
use Koha::Patron::Attribute::Types;
28
29
sub all {
30
    my ( $self, $params ) = @_;
31
    return Koha::Patron::Attribute::Types->search($params);
32
}
33
34
sub codes {
35
    my ( $self, $params ) = @_;
36
    return Koha::Patron::Attribute::Types->search($params)->get_column('code');
37
}
38
39
1;
40
41
=head1 NAME
42
43
Koha::Template::Plugin::ExtendedAttributeTypes - TT Plugin for retrieving patron attribute types
44
45
=head1 SYNOPSIS
46
47
[% USE ExtendedAttributeTypes %]
48
49
[% ExtendedAttributeTypes.all() %]
50
51
=head1 ROUTINES
52
53
=head2 all
54
55
In a template, you can get the searchable attribute types with
56
the following TT code: [% ExtendedAttributes.all( staff_searchable => 1 ) %]
57
58
The function returns the Koha::Patron::Atribute::Type objects
59
60
=head2 codes
61
62
In a template, you can get the searchable attribute type codes with
63
the following TT code: [% ExtendedAttributes.codes( staff_searchable => 1 ) %]
64
65
The function returns the Koha::Patron::Atribute::Type codes as an array
66
67
=head1 AUTHOR
68
69
Nick Clemens <nick@bywatersolutions.com>
70
71
=cut
(-)a/circ/request-article.pl (-4 lines)
Lines 123-132 $template->param( Link Here
123
    patron => $patron,
123
    patron => $patron,
124
    subscriptionsnumber => CountSubscriptionFromBiblionumber($biblionumber),
124
    subscriptionsnumber => CountSubscriptionFromBiblionumber($biblionumber),
125
    C4::Search::enabled_staff_search_views,
125
    C4::Search::enabled_staff_search_views,
126
    attribute_type_codes => ( C4::Context->preference('ExtendedPatronAttributes')
127
        ? [ Koha::Patron::Attribute::Types->search( { staff_searchable => 1 } )->get_column('code') ]
128
        : []
129
    ),
130
);
126
);
131
127
132
128
(-)a/koha-tmpl/intranet-tmpl/prog/en/includes/patron-search.inc (-1 / +3 lines)
Lines 1-6 Link Here
1
[% USE Koha %]
1
[% USE Koha %]
2
[% USE I18N %]
2
[% USE I18N %]
3
[% USE Branches %]
3
[% USE Branches %]
4
[% USE ExtendedAttributeTypes %]
4
[% USE raw %]
5
[% USE raw %]
5
[% USE Asset %]
6
[% USE Asset %]
6
[% USE To %]
7
[% USE To %]
Lines 231-237 Link Here
231
            return map;
232
            return map;
232
        }, {});
233
        }, {});
233
234
234
        [% IF Koha.Preference('ExtendedPatronAttributes') && extended_attribute_types %]
235
        [% IF Koha.Preference('ExtendedPatronAttributes') %]
236
            [% SET extended_attribute_types = ExtendedAttributeTypes.codes( staff_searchable => 1 ) %]
235
            let extended_attribute_types = [% To.json(extended_attribute_types || []) | $raw %];
237
            let extended_attribute_types = [% To.json(extended_attribute_types || []) | $raw %];
236
        [% END %]
238
        [% END %]
237
239
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/request-article.tt (-1 / +1 lines)
Lines 441-447 Link Here
441
        });
441
        });
442
    </script>
442
    </script>
443
443
444
    [% PROCESS patron_search_js table_id => 'table_borrowers', categories => categories, libraries => libraries, extended_attribute_types => attribute_type_codes, columns => columns, open_on_row_click => 1, on_click_url => '/cgi-bin/koha/circ/request-article.pl?biblionumber=' _ biblio.biblionumber, redirect_if_one_result => 1, redirect_url => '/cgi-bin/koha/circ/request-article.pl?biblionumber=' _ biblio.biblionumber %]
444
    [% PROCESS patron_search_js table_id => 'table_borrowers', categories => categories, libraries => libraries, columns => columns, open_on_row_click => 1, on_click_url => '/cgi-bin/koha/circ/request-article.pl?biblionumber=' _ biblio.biblionumber, redirect_if_one_result => 1, redirect_url => '/cgi-bin/koha/circ/request-article.pl?biblionumber=' _ biblio.biblionumber %]
445
445
446
[% END %]
446
[% END %]
447
447
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/members/member.tt (-1 / +1 lines)
Lines 390-396 Link Here
390
    [% ELSE %]
390
    [% ELSE %]
391
        [% SET redirect_url = '/cgi-bin/koha/members/moremember.pl' %]
391
        [% SET redirect_url = '/cgi-bin/koha/members/moremember.pl' %]
392
    [% END %]
392
    [% END %]
393
    [% PROCESS patron_search_js table_id => 'memberresultst', categories => categories, libraries => libraries, extended_attribute_types => attribute_type_codes, columns => columns,actions => ['edit', 'checkout'], redirect_if_one_result => 1, redirect_url => redirect_url, sticky_header => "searchheader", sticky_to => "searchresults", default_sort_column => 'name-address', display_search_description => 1, remember_selections => 1 %]
393
    [% PROCESS patron_search_js table_id => 'memberresultst', categories => categories, libraries => libraries, columns => columns,actions => ['edit', 'checkout'], redirect_if_one_result => 1, redirect_url => redirect_url, sticky_header => "searchheader", sticky_to => "searchresults", default_sort_column => 'name-address', display_search_description => 1, remember_selections => 1 %]
394
394
395
[% END %]
395
[% END %]
396
[% INCLUDE 'intranet-bottom.inc' %]
396
[% INCLUDE 'intranet-bottom.inc' %]
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/members/search.tt (-1 / +1 lines)
Lines 77-83 Link Here
77
    });
77
    });
78
</script>
78
</script>
79
79
80
    [% PROCESS patron_search_js table_id => 'memberresultst', categories => categories, libraries => libraries, extended_attribute_types => attribute_type_codes, columns => columns, filter => filter, actions => [selection_type], preview_on_name_click => 1, callback => callback %]
80
    [% PROCESS patron_search_js table_id => 'memberresultst', categories => categories, libraries => libraries, columns => columns, filter => filter, actions => [selection_type], preview_on_name_click => 1, callback => callback %]
81
[% END %]
81
[% END %]
82
82
83
[% SET popup_window = 1 %]
83
[% SET popup_window = 1 %]
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/reserve/request.tt (-1 / +1 lines)
Lines 1741-1747 Link Here
1741
        table_settings = [% TablesSettings.GetColumns( 'circ', 'circulation', 'table_borrowers', 'json' ) | $raw %];
1741
        table_settings = [% TablesSettings.GetColumns( 'circ', 'circulation', 'table_borrowers', 'json' ) | $raw %];
1742
    </script>
1742
    </script>
1743
1743
1744
    [% PROCESS patron_search_js table_id => 'table_borrowers', categories => categories, libraries => libraries, extended_attribute_types => attribute_type_codes, columns => columns, open_on_row_click => 1, on_click_url => '/cgi-bin/koha/reserve/request.pl?' _ url_biblio_params, redirect_if_one_result => 1, redirect_url => '/cgi-bin/koha/reserve/request.pl?' _ url_biblio_params, redirect_if_attribute_equal => 'cardnumber' %]
1744
    [% PROCESS patron_search_js table_id => 'table_borrowers', categories => categories, libraries => libraries, columns => columns, open_on_row_click => 1, on_click_url => '/cgi-bin/koha/reserve/request.pl?' _ url_biblio_params, redirect_if_one_result => 1, redirect_url => '/cgi-bin/koha/reserve/request.pl?' _ url_biblio_params, redirect_if_attribute_equal => 'cardnumber' %]
1745
    <script>
1745
    <script>
1746
        $(document).ready(function() {
1746
        $(document).ready(function() {
1747
            $("#holds_patronsearch").on("submit", filter);
1747
            $("#holds_patronsearch").on("submit", filter);
(-)a/members/member.pl (-3 lines)
Lines 81-89 $template->param( Link Here
81
    PatronsPerPage      => C4::Context->preference("PatronsPerPage") || 20,
81
    PatronsPerPage      => C4::Context->preference("PatronsPerPage") || 20,
82
    do_not_defer_loading => !$defer_loading,
82
    do_not_defer_loading => !$defer_loading,
83
    circsearch          => $circsearch,
83
    circsearch          => $circsearch,
84
    attribute_type_codes => ( C4::Context->preference('ExtendedPatronAttributes')
85
        ? [ Koha::Patron::Attribute::Types->search( { staff_searchable => 1 } )->get_column('code') ]
86
        : [] ),
87
);
84
);
88
85
89
output_html_with_http_headers $input, $cookie, $template->output;
86
output_html_with_http_headers $input, $cookie, $template->output;
(-)a/members/members-home.pl (-3 lines)
Lines 73-81 $template->param( Link Here
73
    PatronAutoComplete => C4::Context->preference('PatronAutoComplete'),
73
    PatronAutoComplete => C4::Context->preference('PatronAutoComplete'),
74
    patron_lists => [ GetPatronLists() ],
74
    patron_lists => [ GetPatronLists() ],
75
    PatronsPerPage => C4::Context->preference("PatronsPerPage") || 20,
75
    PatronsPerPage => C4::Context->preference("PatronsPerPage") || 20,
76
    attribute_type_codes => ( C4::Context->preference('ExtendedPatronAttributes')
77
        ? [ Koha::Patron::Attribute::Types->search( { staff_searchable => 1 } )->get_column('code') ]
78
        : [] ),
79
);
76
);
80
77
81
output_html_with_http_headers $query, $cookie, $template->output;
78
output_html_with_http_headers $query, $cookie, $template->output;
(-)a/members/search.pl (-3 lines)
Lines 46-53 $template->param( Link Here
46
    columns        => \@columns,
46
    columns        => \@columns,
47
    filter         => $filter,
47
    filter         => $filter,
48
    selection_type => $selection_type,
48
    selection_type => $selection_type,
49
    attribute_type_codes => ( C4::Context->preference('ExtendedPatronAttributes')
50
        ? [ Koha::Patron::Attribute::Types->search( { staff_searchable => 1 } )->get_column('code') ]
51
        : [] ),
52
);
49
);
53
output_html_with_http_headers( $input, $cookie, $template->output );
50
output_html_with_http_headers( $input, $cookie, $template->output );
(-)a/reserve/request.pl (-9 lines)
Lines 704-717 if ( ( $findborrower && $borrowernumber_hold || $findclub && $club_hold ) Link Here
704
}
704
}
705
$template->param( biblionumbers => \@biblionumbers );
705
$template->param( biblionumbers => \@biblionumbers );
706
706
707
$template->param(
708
    attribute_type_codes => ( C4::Context->preference('ExtendedPatronAttributes')
709
        ? [ Koha::Patron::Attribute::Types->search( { staff_searchable => 1 } )->get_column('code') ]
710
        : []
711
    ),
712
);
713
714
715
# pass the userenv branch if no pickup location selected
707
# pass the userenv branch if no pickup location selected
716
$template->param( pickup => $pickup || C4::Context->userenv->{branch} );
708
$template->param( pickup => $pickup || C4::Context->userenv->{branch} );
717
709
718
- 

Return to bug 34519