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

(-)a/C4/ItemCirculationAlertPreference.pm (-1 / +1 lines)
Lines 331-337 sub grid { Link Here
331
    my ($class, $where) = @_;
331
    my ($class, $where) = @_;
332
    my @branch_prefs = $class->find($where);
332
    my @branch_prefs = $class->find($where);
333
    my @default_prefs = $class->find({ branchcode => '*', notification => $where->{notification} });
333
    my @default_prefs = $class->find({ branchcode => '*', notification => $where->{notification} });
334
    my @cc = Koha::Patron::Categories->search_limited;
334
    my @cc = Koha::Patron::Categories->search_with_library_limits;
335
    my @it = Koha::ItemTypes->search;
335
    my @it = Koha::ItemTypes->search;
336
    my $notification = $where->{notification};
336
    my $notification = $where->{notification};
337
    my %disabled = map {
337
    my %disabled = map {
(-)a/Koha/Patron/Categories.pm (-12 / +1 lines)
Lines 25-31 use Koha::Database; Link Here
25
25
26
use Koha::Patron::Category;
26
use Koha::Patron::Category;
27
27
28
use base qw(Koha::Objects);
28
use base qw(Koha::Objects Koha::Objects::Limit::Library);
29
29
30
=head1 NAME
30
=head1 NAME
31
31
Lines 37-53 Koha::Patron::Categories - Koha Patron Category Object set class Link Here
37
37
38
=cut
38
=cut
39
39
40
sub search_limited {
41
    my ( $self, $params, $attributes ) = @_;
42
    my $branch_limit = C4::Context->userenv ? C4::Context->userenv->{"branch"} : "";
43
    if ( $branch_limit ) {
44
        $params->{'categories_branches.branchcode'} = [ $branch_limit, undef ];
45
        $attributes->{join} = 'categories_branches';
46
    }
47
    $attributes->{order_by} = ['description'] unless $attributes->{order_by};
48
    return $self->search($params, $attributes);
49
}
50
51
=head3 type
40
=head3 type
52
41
53
=cut
42
=cut
(-)a/Koha/Template/Plugin/Categories.pm (-1 / +1 lines)
Lines 25-31 use Koha::Patron::Categories; Link Here
25
25
26
sub all {
26
sub all {
27
    my ( $self, $params ) = @_;
27
    my ( $self, $params ) = @_;
28
    return Koha::Patron::Categories->search_limited($params);
28
    return Koha::Patron::Categories->search_with_library_limits($params);
29
}
29
}
30
30
31
sub GetName {
31
sub GetName {
(-)a/acqui/add_user_search.pl (-1 / +1 lines)
Lines 51-57 my $search_patrons_with_acq_perm_only = Link Here
51
    ( $referer =~ m|acqui/basket.pl| )
51
    ( $referer =~ m|acqui/basket.pl| )
52
        ? 1 : 0;
52
        ? 1 : 0;
53
53
54
my $patron_categories = Koha::Patron::Categories->search_limited;
54
my $patron_categories = Koha::Patron::Categories->search_with_library_limits;
55
$template->param(
55
$template->param(
56
    patrons_with_acq_perm_only => $search_patrons_with_acq_perm_only,
56
    patrons_with_acq_perm_only => $search_patrons_with_acq_perm_only,
57
    view => ( $input->request_method() eq "GET" ) ? "show_form" : "show_results",
57
    view => ( $input->request_method() eq "GET" ) ? "show_form" : "show_results",
(-)a/admin/add_user_search.pl (-1 / +1 lines)
Lines 52-58 my $search_patrons_with_acq_perm_only = Link Here
52
    ( $referer =~ m|admin/aqbudgets.pl| )
52
    ( $referer =~ m|admin/aqbudgets.pl| )
53
        ? 1 : 0;
53
        ? 1 : 0;
54
54
55
my $patron_categories = Koha::Patron::Categories->search_limited;
55
my $patron_categories = Koha::Patron::Categories->search_with_library_limits;
56
$template->param(
56
$template->param(
57
    patrons_with_acq_perm_only => $search_patrons_with_acq_perm_only,
57
    patrons_with_acq_perm_only => $search_patrons_with_acq_perm_only,
58
    view => ( $input->request_method() eq "GET" ) ? "show_form" : "show_results",
58
    view => ( $input->request_method() eq "GET" ) ? "show_form" : "show_results",
(-)a/admin/item_circulation_alerts.pl (-1 / +1 lines)
Lines 50-56 sub show { Link Here
50
    );
50
    );
51
51
52
    my $branch   = $input->param('branch') || '*';
52
    my $branch   = $input->param('branch') || '*';
53
    my @categories = Koha::Patron::Categories->search_limited;
53
    my @categories = Koha::Patron::Categories->search_with_library_limits;
54
    my @item_types = Koha::ItemTypes->search;
54
    my @item_types = Koha::ItemTypes->search;
55
    my $grid_checkout = $preferences->grid({ branchcode => $branch, notification => 'CHECKOUT' });
55
    my $grid_checkout = $preferences->grid({ branchcode => $branch, notification => 'CHECKOUT' });
56
    my $grid_checkin  = $preferences->grid({ branchcode => $branch, notification => 'CHECKIN' });
56
    my $grid_checkin  = $preferences->grid({ branchcode => $branch, notification => 'CHECKIN' });
(-)a/admin/patron-attr-types.pl (-1 / +1 lines)
Lines 95-101 sub add_attribute_type_form { Link Here
95
        };
95
        };
96
    }
96
    }
97
97
98
    my $patron_categories = Koha::Patron::Categories->search_limited({}, {order_by => ['description']});
98
    my $patron_categories = Koha::Patron::Categories->search_with_library_limlits({}, {order_by => ['description']});
99
    $template->param(
99
    $template->param(
100
        attribute_type_form => 1,
100
        attribute_type_form => 1,
101
        confirm_op => 'add_attribute_type_confirmed',
101
        confirm_op => 'add_attribute_type_confirmed',
(-)a/members/guarantor_search.pl (-1 / +1 lines)
Lines 44-50 my $op = $input->param('op') || ''; Link Here
44
44
45
my $referer = $input->referer();
45
my $referer = $input->referer();
46
46
47
my $patron_categories = Koha::Patron::Categories->search_limited;
47
my $patron_categories = Koha::Patron::Categories->search_with_library_limits;
48
$template->param(
48
$template->param(
49
    view => ( $input->request_method() eq "GET" ) ? "show_form" : "show_results",
49
    view => ( $input->request_method() eq "GET" ) ? "show_form" : "show_results",
50
    columns => ['cardnumber', 'name', 'dateofbirth', 'address', 'action' ],
50
    columns => ['cardnumber', 'name', 'dateofbirth', 'address', 'action' ],
(-)a/members/memberentry.pl (-1 / +1 lines)
Lines 612-618 my @typeloop; Link Here
612
my $no_categories = 1;
612
my $no_categories = 1;
613
my $no_add;
613
my $no_add;
614
foreach my $category_type (qw(C A S P I X)) {
614
foreach my $category_type (qw(C A S P I X)) {
615
    my $patron_categories = Koha::Patron::Categories->search_limited({ category_type => $category_type }, {order_by => ['categorycode']});
615
    my $patron_categories = Koha::Patron::Categories->search_with_library_limits({ category_type => $category_type }, {order_by => ['categorycode']});
616
    $no_categories = 0 if $patron_categories->count > 0;
616
    $no_categories = 0 if $patron_categories->count > 0;
617
617
618
    my @categoryloop;
618
    my @categoryloop;
(-)a/members/members-home.pl (-1 / +1 lines)
Lines 45-51 if( Koha::Libraries->search->count < 1){ Link Here
45
    $template->param(no_branches => 1);
45
    $template->param(no_branches => 1);
46
}
46
}
47
47
48
my @categories = Koha::Patron::Categories->search_limited;
48
my @categories = Koha::Patron::Categories->search_with_library_limits;
49
if(scalar(@categories) < 1){
49
if(scalar(@categories) < 1){
50
    $no_add = 1;
50
    $no_add = 1;
51
    $template->param(no_categories => 1);
51
    $template->param(no_categories => 1);
(-)a/members/update-child.pl (-1 / +1 lines)
Lines 58-64 my $op = $input->param('op'); Link Here
58
58
59
my $logged_in_user = Koha::Patrons->find( $loggedinuser ) or die "Not logged in";
59
my $logged_in_user = Koha::Patrons->find( $loggedinuser ) or die "Not logged in";
60
60
61
my $patron_categories = Koha::Patron::Categories->search_limited({ category_type => 'A' }, {order_by => ['categorycode']});
61
my $patron_categories = Koha::Patron::Categories->search_with_library_limits({ category_type => 'A' }, {order_by => ['categorycode']});
62
if ( $op eq 'multi' ) {
62
if ( $op eq 'multi' ) {
63
    # FIXME - what are the possible upgrade paths?  C -> A , C -> S ...
63
    # FIXME - what are the possible upgrade paths?  C -> A , C -> S ...
64
    #   currently just allowing C -> A
64
    #   currently just allowing C -> A
(-)a/patroncards/add_user_search.pl (-1 / +1 lines)
Lines 44-50 my $op = $input->param('op') || ''; Link Here
44
44
45
my $referer = $input->referer();
45
my $referer = $input->referer();
46
46
47
my $patron_categories = Koha::Patron::Categories->search_limited;
47
my $patron_categories = Koha::Patron::Categories->search_with_library_limits;
48
$template->param(
48
$template->param(
49
    view            => ( $input->request_method() eq "GET" ) ? "show_form" : "show_results",
49
    view            => ( $input->request_method() eq "GET" ) ? "show_form" : "show_results",
50
    columns         => ['cardnumber', 'name', 'category', 'branch', 'dateexpiry', 'borrowernotes', 'action'],
50
    columns         => ['cardnumber', 'name', 'category', 'branch', 'dateexpiry', 'borrowernotes', 'action'],
(-)a/reports/bor_issues_top.pl (-1 / +1 lines)
Lines 110-116 my @values; Link Here
110
my @mime  = ( map { {type =>$_} } (split /[;:]/, 'CSV') ); # FIXME translation
110
my @mime  = ( map { {type =>$_} } (split /[;:]/, 'CSV') ); # FIXME translation
111
my $delims = GetDelimiterChoices;
111
my $delims = GetDelimiterChoices;
112
112
113
my $patron_categories = Koha::Patron::Categories->search_limited({}, {order_by => ['categorycode']});
113
my $patron_categories = Koha::Patron::Categories->search_with_library_limits({}, {order_by => ['categorycode']});
114
my $itemtypes = Koha::ItemTypes->search_with_localization;
114
my $itemtypes = Koha::ItemTypes->search_with_localization;
115
$template->param(
115
$template->param(
116
	    mimeloop => \@mime,
116
	    mimeloop => \@mime,
(-)a/reports/borrowers_out.pl (-1 / +1 lines)
Lines 118-124 if ($do_it) { Link Here
118
    my $CGIextChoice = ( 'CSV' ); # FIXME translation
118
    my $CGIextChoice = ( 'CSV' ); # FIXME translation
119
	my $CGIsepChoice = GetDelimiterChoices;
119
	my $CGIsepChoice = GetDelimiterChoices;
120
120
121
    my $patron_categories = Koha::Patron::Categories->search_limited({}, {order_by => ['categorycode']});
121
    my $patron_categories = Koha::Patron::Categories->search_with_library_limits({}, {order_by => ['categorycode']});
122
    $template->param(
122
    $template->param(
123
                    CGIextChoice => $CGIextChoice,
123
                    CGIextChoice => $CGIextChoice,
124
                    CGIsepChoice => $CGIsepChoice,
124
                    CGIsepChoice => $CGIsepChoice,
(-)a/reports/cat_issues_top.pl (-1 / +1 lines)
Lines 133-139 if ($do_it) { Link Here
133
133
134
    @shelvinglocloop = sort {$a->{value} cmp $b->{value}} @shelvinglocloop;
134
    @shelvinglocloop = sort {$a->{value} cmp $b->{value}} @shelvinglocloop;
135
135
136
    my $patron_categories = Koha::Patron::Categories->search_limited({}, {order_by => ['categorycode']});
136
    my $patron_categories = Koha::Patron::Categories->search_with_library_limits({}, {order_by => ['categorycode']});
137
137
138
    $template->param(
138
    $template->param(
139
                    CGIextChoice => $CGIextChoice,
139
                    CGIextChoice => $CGIextChoice,
(-)a/reports/issues_stats.pl (-1 / +1 lines)
Lines 89-95 $template->param(do_it => $do_it, Link Here
89
89
90
our $itemtypes = Koha::ItemTypes->search_with_localization->unblessed;
90
our $itemtypes = Koha::ItemTypes->search_with_localization->unblessed;
91
91
92
our @patron_categories = Koha::Patron::Categories->search_limited({}, {order_by => ['description']});
92
our @patron_categories = Koha::Patron::Categories->search_with_library_limits({}, {order_by => ['description']});
93
93
94
our $locations = { map { ( $_->{authorised_value} => $_->{lib} ) } Koha::AuthorisedValues->get_descriptions_by_koha_field( { frameworkcode => '', kohafield => 'items.location' }, { order_by => ['description'] } ) };
94
our $locations = { map { ( $_->{authorised_value} => $_->{lib} ) } Koha::AuthorisedValues->get_descriptions_by_koha_field( { frameworkcode => '', kohafield => 'items.location' }, { order_by => ['description'] } ) };
95
our $ccodes = { map { ( $_->{authorised_value} => $_->{lib} ) } Koha::AuthorisedValues->get_descriptions_by_koha_field( { frameworkcode => '', kohafield => 'items.ccode' }, { order_by => ['description'] } ) };
95
our $ccodes = { map { ( $_->{authorised_value} => $_->{lib} ) } Koha::AuthorisedValues->get_descriptions_by_koha_field( { frameworkcode => '', kohafield => 'items.ccode' }, { order_by => ['description'] } ) };
(-)a/reports/reserves_stats.pl (-2 / +2 lines)
Lines 75-81 $sep = "\t" if ($sep eq 'tabulation'); Link Here
75
$template->param(do_it => $do_it,
75
$template->param(do_it => $do_it,
76
);
76
);
77
77
78
my @patron_categories = Koha::Patron::Categories->search_limited({}, {order_by => ['description']});
78
my @patron_categories = Koha::Patron::Categories->search_with_library_limits({}, {order_by => ['description']});
79
79
80
my $locations = { map { ( $_->{authorised_value} => $_->{lib} ) } Koha::AuthorisedValues->get_descriptions_by_koha_field( { frameworkcode => '', kohafield => 'items.location' }, { order_by => ['description'] } ) };
80
my $locations = { map { ( $_->{authorised_value} => $_->{lib} ) } Koha::AuthorisedValues->get_descriptions_by_koha_field( { frameworkcode => '', kohafield => 'items.location' }, { order_by => ['description'] } ) };
81
my $ccodes = { map { ( $_->{authorised_value} => $_->{lib} ) } Koha::AuthorisedValues->get_descriptions_by_koha_field( { frameworkcode => '', kohafield => 'items.ccode' }, { order_by => ['description'] } ) };
81
my $ccodes = { map { ( $_->{authorised_value} => $_->{lib} ) } Koha::AuthorisedValues->get_descriptions_by_koha_field( { frameworkcode => '', kohafield => 'items.ccode' }, { order_by => ['description'] } ) };
Lines 337-343 sub display_value { Link Here
337
        }
337
        }
338
    }
338
    }
339
    elsif ( $crit =~ /category/ ) {
339
    elsif ( $crit =~ /category/ ) {
340
        my @patron_categories = Koha::Patron::Categories->search_limited({}, {order_by => ['description']});
340
        my @patron_categories = Koha::Patron::Categories->search_with_library_limits({}, {order_by => ['description']});
341
        foreach my $patron_category ( @patron_categories ) {
341
        foreach my $patron_category ( @patron_categories ) {
342
            ( $value eq $patron_category->categorycode ) or next;
342
            ( $value eq $patron_category->categorycode ) or next;
343
            $display_value = $patron_category->description and last;
343
            $display_value = $patron_category->description and last;
(-)a/serials/add_user_search.pl (-1 / +1 lines)
Lines 44-50 my $op = $input->param('op') || ''; Link Here
44
44
45
my $referer = $input->referer();
45
my $referer = $input->referer();
46
46
47
my $patron_categories = Koha::Patron::Categories->search_limited;
47
my $patron_categories = Koha::Patron::Categories->search_with_library_limits;
48
$template->param(
48
$template->param(
49
    view => ( $input->request_method() eq "GET" ) ? "show_form" : "show_results",
49
    view => ( $input->request_method() eq "GET" ) ? "show_form" : "show_results",
50
    columns => ['cardnumber', 'name', 'branch', 'action'],
50
    columns => ['cardnumber', 'name', 'branch', 'action'],
(-)a/t/db_dependent/Utils/Datatables_Virtualshelves.t (-1 / +1 lines)
Lines 38-44 my $dbh = C4::Context->dbh; Link Here
38
$dbh->do(q|DELETE FROM virtualshelves|);
38
$dbh->do(q|DELETE FROM virtualshelves|);
39
39
40
# Pick a categorycode from the DB
40
# Pick a categorycode from the DB
41
my @categories   = Koha::Patron::Categories->search_limited;
41
my @categories   = Koha::Patron::Categories->search_with_library_limits;
42
my $categorycode = $categories[0]->categorycode;
42
my $categorycode = $categories[0]->categorycode;
43
my $branchcode   = "ABC";
43
my $branchcode   = "ABC";
44
my $branch_data = {
44
my $branch_data = {
(-)a/tools/cleanborrowers.pl (-1 / +1 lines)
Lines 179-185 elsif ( $step == 3 ) { Link Here
179
    $template->param( patron_lists => [ @non_empty_lists ] );
179
    $template->param( patron_lists => [ @non_empty_lists ] );
180
}
180
}
181
181
182
my $patron_categories = Koha::Patron::Categories->search_limited({}, {order_by => ['description']});
182
my $patron_categories = Koha::Patron::Categories->search_with_library_limits({}, {order_by => ['description']});
183
183
184
$template->param(
184
$template->param(
185
    step                   => $step,
185
    step                   => $step,
(-)a/tools/import_borrowers.pl (-1 / +1 lines)
Lines 80-86 my ( $template, $loggedinuser, $cookie ) = get_template_and_user( Link Here
80
);
80
);
81
81
82
# get the patron categories and pass them to the template
82
# get the patron categories and pass them to the template
83
my @patron_categories = Koha::Patron::Categories->search_limited({}, {order_by => ['description']});
83
my @patron_categories = Koha::Patron::Categories->search_with_library_limits({}, {order_by => ['description']});
84
$template->param( categories => \@patron_categories );
84
$template->param( categories => \@patron_categories );
85
my $columns = C4::Templates::GetColumnDefs( $input )->{borrowers};
85
my $columns = C4::Templates::GetColumnDefs( $input )->{borrowers};
86
$columns = [ grep { $_->{field} ne 'borrowernumber' ? $_ : () } @$columns ];
86
$columns = [ grep { $_->{field} ne 'borrowernumber' ? $_ : () } @$columns ];
(-)a/tools/modborrowers.pl (-2 / +1 lines)
Lines 115-121 if ( $op eq 'show' ) { Link Here
115
    my @patron_attributes_values;
115
    my @patron_attributes_values;
116
    my @patron_attributes_codes;
116
    my @patron_attributes_codes;
117
    my $patron_attribute_types = C4::Members::AttributeTypes::GetAttributeTypes_hashref('all');
117
    my $patron_attribute_types = C4::Members::AttributeTypes::GetAttributeTypes_hashref('all');
118
    my @patron_categories = Koha::Patron::Categories->search_limited({}, {order_by => ['description']});
118
    my @patron_categories = Koha::Patron::Categories->search_with_library_limits({}, {order_by => ['description']});
119
    for ( values %$patron_attribute_types ) {
119
    for ( values %$patron_attribute_types ) {
120
        my $attr_type = C4::Members::AttributeTypes->fetch( $_->{code} );
120
        my $attr_type = C4::Members::AttributeTypes->fetch( $_->{code} );
121
        # TODO Repeatable attributes are not correctly managed and can cause data lost.
121
        # TODO Repeatable attributes are not correctly managed and can cause data lost.
122
- 

Return to bug 23271