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 50-56 my $search_patrons_with_acq_perm_only = Link Here
50
    ( $referer =~ m|acqui/basket.pl| )
50
    ( $referer =~ m|acqui/basket.pl| )
51
        ? 1 : 0;
51
        ? 1 : 0;
52
52
53
my $patron_categories = Koha::Patron::Categories->search_limited;
53
my $patron_categories = Koha::Patron::Categories->search_with_library_limits;
54
$template->param(
54
$template->param(
55
    patrons_with_acq_perm_only => $search_patrons_with_acq_perm_only,
55
    patrons_with_acq_perm_only => $search_patrons_with_acq_perm_only,
56
    view => ( $input->request_method() eq "GET" ) ? "show_form" : "show_results",
56
    view => ( $input->request_method() eq "GET" ) ? "show_form" : "show_results",
(-)a/admin/add_user_search.pl (-1 / +1 lines)
Lines 51-57 my $search_patrons_with_acq_perm_only = Link Here
51
    ( $referer =~ m|admin/aqbudgets.pl| )
51
    ( $referer =~ m|admin/aqbudgets.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/item_circulation_alerts.pl (-1 / +1 lines)
Lines 49-55 sub show { Link Here
49
    );
49
    );
50
50
51
    my $branch   = $input->param('branch') || '*';
51
    my $branch   = $input->param('branch') || '*';
52
    my @categories = Koha::Patron::Categories->search_limited;
52
    my @categories = Koha::Patron::Categories->search_with_library_limits;
53
    my @item_types = Koha::ItemTypes->search;
53
    my @item_types = Koha::ItemTypes->search;
54
    my $grid_checkout = $preferences->grid({ branchcode => $branch, notification => 'CHECKOUT' });
54
    my $grid_checkout = $preferences->grid({ branchcode => $branch, notification => 'CHECKOUT' });
55
    my $grid_checkin  = $preferences->grid({ branchcode => $branch, notification => 'CHECKIN' });
55
    my $grid_checkin  = $preferences->grid({ branchcode => $branch, notification => 'CHECKIN' });
(-)a/admin/patron-attr-types.pl (-1 / +1 lines)
Lines 85-91 exit 0; Link Here
85
sub add_attribute_type_form {
85
sub add_attribute_type_form {
86
    my $template = shift;
86
    my $template = shift;
87
87
88
    my $patron_categories = Koha::Patron::Categories->search_limited({}, {order_by => ['description']});
88
    my $patron_categories = Koha::Patron::Categories->search_with_library_limlits({}, {order_by => ['description']});
89
    $template->param(
89
    $template->param(
90
        attribute_type_form => 1,
90
        attribute_type_form => 1,
91
        confirm_op => 'add_attribute_type_confirmed',
91
        confirm_op => 'add_attribute_type_confirmed',
(-)a/members/guarantor_search.pl (-1 / +1 lines)
Lines 43-49 my $op = $input->param('op') || ''; Link Here
43
43
44
my $referer = $input->referer();
44
my $referer = $input->referer();
45
45
46
my $patron_categories = Koha::Patron::Categories->search_limited;
46
my $patron_categories = Koha::Patron::Categories->search_with_library_limits;
47
$template->param(
47
$template->param(
48
    view => ( $input->request_method() eq "GET" ) ? "show_form" : "show_results",
48
    view => ( $input->request_method() eq "GET" ) ? "show_form" : "show_results",
49
    columns => ['cardnumber', 'name', 'dateofbirth', 'address', 'action' ],
49
    columns => ['cardnumber', 'name', 'dateofbirth', 'address', 'action' ],
(-)a/members/memberentry.pl (-1 / +1 lines)
Lines 673-679 my @typeloop; Link Here
673
my $no_categories = 1;
673
my $no_categories = 1;
674
my $no_add;
674
my $no_add;
675
foreach my $category_type (qw(C A S P I X)) {
675
foreach my $category_type (qw(C A S P I X)) {
676
    my $patron_categories = Koha::Patron::Categories->search_limited({ category_type => $category_type }, {order_by => ['categorycode']});
676
    my $patron_categories = Koha::Patron::Categories->search_with_library_limits({ category_type => $category_type }, {order_by => ['categorycode']});
677
    $no_categories = 0 if $patron_categories->count > 0;
677
    $no_categories = 0 if $patron_categories->count > 0;
678
678
679
    my @categoryloop;
679
    my @categoryloop;
(-)a/members/members-home.pl (-1 / +1 lines)
Lines 44-50 if( Koha::Libraries->search->count < 1){ Link Here
44
    $template->param(no_branches => 1);
44
    $template->param(no_branches => 1);
45
}
45
}
46
46
47
my @categories = Koha::Patron::Categories->search_limited;
47
my @categories = Koha::Patron::Categories->search_with_library_limits;
48
if(scalar(@categories) < 1){
48
if(scalar(@categories) < 1){
49
    $no_add = 1;
49
    $no_add = 1;
50
    $template->param(no_categories => 1);
50
    $template->param(no_categories => 1);
(-)a/members/update-child.pl (-1 / +1 lines)
Lines 57-63 my $op = $input->param('op'); Link Here
57
57
58
my $logged_in_user = Koha::Patrons->find( $loggedinuser );
58
my $logged_in_user = Koha::Patrons->find( $loggedinuser );
59
59
60
my $patron_categories = Koha::Patron::Categories->search_limited({ category_type => 'A' }, {order_by => ['categorycode']});
60
my $patron_categories = Koha::Patron::Categories->search_with_library_limits({ category_type => 'A' }, {order_by => ['categorycode']});
61
if ( $op eq 'multi' ) {
61
if ( $op eq 'multi' ) {
62
    # FIXME - what are the possible upgrade paths?  C -> A , C -> S ...
62
    # FIXME - what are the possible upgrade paths?  C -> A , C -> S ...
63
    #   currently just allowing C -> A
63
    #   currently just allowing C -> A
(-)a/patroncards/add_user_search.pl (-1 / +1 lines)
Lines 43-49 my $op = $input->param('op') || ''; Link Here
43
43
44
my $referer = $input->referer();
44
my $referer = $input->referer();
45
45
46
my $patron_categories = Koha::Patron::Categories->search_limited;
46
my $patron_categories = Koha::Patron::Categories->search_with_library_limits;
47
$template->param(
47
$template->param(
48
    view            => ( $input->request_method() eq "GET" ) ? "show_form" : "show_results",
48
    view            => ( $input->request_method() eq "GET" ) ? "show_form" : "show_results",
49
    columns         => ['cardnumber', 'name', 'category', 'branch', 'dateexpiry', 'borrowernotes', 'action'],
49
    columns         => ['cardnumber', 'name', 'category', 'branch', 'dateexpiry', 'borrowernotes', 'action'],
(-)a/reports/bor_issues_top.pl (-1 / +1 lines)
Lines 108-114 my $dbh = C4::Context->dbh; Link Here
108
my @mime  = ( map { {type =>$_} } (split /[;:]/, 'CSV') ); # FIXME translation
108
my @mime  = ( map { {type =>$_} } (split /[;:]/, 'CSV') ); # FIXME translation
109
my $delims = GetDelimiterChoices;
109
my $delims = GetDelimiterChoices;
110
110
111
my $patron_categories = Koha::Patron::Categories->search_limited({}, {order_by => ['categorycode']});
111
my $patron_categories = Koha::Patron::Categories->search_with_library_limits({}, {order_by => ['categorycode']});
112
my $itemtypes = Koha::ItemTypes->search_with_localization;
112
my $itemtypes = Koha::ItemTypes->search_with_localization;
113
$template->param(
113
$template->param(
114
	    mimeloop => \@mime,
114
	    mimeloop => \@mime,
(-)a/reports/borrowers_out.pl (-1 / +1 lines)
Lines 113-119 if ($do_it) { Link Here
113
    my $CGIextChoice = ( 'CSV' ); # FIXME translation
113
    my $CGIextChoice = ( 'CSV' ); # FIXME translation
114
	my $CGIsepChoice = GetDelimiterChoices;
114
	my $CGIsepChoice = GetDelimiterChoices;
115
115
116
    my $patron_categories = Koha::Patron::Categories->search_limited({}, {order_by => ['categorycode']});
116
    my $patron_categories = Koha::Patron::Categories->search_with_library_limits({}, {order_by => ['categorycode']});
117
    $template->param(
117
    $template->param(
118
                    CGIextChoice => $CGIextChoice,
118
                    CGIextChoice => $CGIextChoice,
119
                    CGIsepChoice => $CGIsepChoice,
119
                    CGIsepChoice => $CGIsepChoice,
(-)a/reports/cat_issues_top.pl (-1 / +1 lines)
Lines 132-138 if ($do_it) { Link Here
132
132
133
    @shelvinglocloop = sort {$a->{value} cmp $b->{value}} @shelvinglocloop;
133
    @shelvinglocloop = sort {$a->{value} cmp $b->{value}} @shelvinglocloop;
134
134
135
    my $patron_categories = Koha::Patron::Categories->search_limited({}, {order_by => ['categorycode']});
135
    my $patron_categories = Koha::Patron::Categories->search_with_library_limits({}, {order_by => ['categorycode']});
136
136
137
    $template->param(
137
    $template->param(
138
                    CGIextChoice => $CGIextChoice,
138
                    CGIextChoice => $CGIextChoice,
(-)a/reports/issues_stats.pl (-1 / +1 lines)
Lines 88-94 $template->param(do_it => $do_it, Link Here
88
88
89
our $itemtypes = Koha::ItemTypes->search_with_localization->unblessed;
89
our $itemtypes = Koha::ItemTypes->search_with_localization->unblessed;
90
90
91
our @patron_categories = Koha::Patron::Categories->search_limited({}, {order_by => ['description']});
91
our @patron_categories = Koha::Patron::Categories->search_with_library_limits({}, {order_by => ['description']});
92
92
93
our $locations = { map { ( $_->{authorised_value} => $_->{lib} ) } Koha::AuthorisedValues->get_descriptions_by_koha_field( { frameworkcode => '', kohafield => 'items.location' }, { order_by => ['description'] } ) };
93
our $locations = { map { ( $_->{authorised_value} => $_->{lib} ) } Koha::AuthorisedValues->get_descriptions_by_koha_field( { frameworkcode => '', kohafield => 'items.location' }, { order_by => ['description'] } ) };
94
our $ccodes = { map { ( $_->{authorised_value} => $_->{lib} ) } Koha::AuthorisedValues->get_descriptions_by_koha_field( { frameworkcode => '', kohafield => 'items.ccode' }, { order_by => ['description'] } ) };
94
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 73-79 $sep = "\t" if ($sep eq 'tabulation'); Link Here
73
$template->param(do_it => $do_it,
73
$template->param(do_it => $do_it,
74
);
74
);
75
75
76
my @patron_categories = Koha::Patron::Categories->search_limited({}, {order_by => ['description']});
76
my @patron_categories = Koha::Patron::Categories->search_with_library_limits({}, {order_by => ['description']});
77
77
78
my $locations = { map { ( $_->{authorised_value} => $_->{lib} ) } Koha::AuthorisedValues->get_descriptions_by_koha_field( { frameworkcode => '', kohafield => 'items.location' }, { order_by => ['description'] } ) };
78
my $locations = { map { ( $_->{authorised_value} => $_->{lib} ) } Koha::AuthorisedValues->get_descriptions_by_koha_field( { frameworkcode => '', kohafield => 'items.location' }, { order_by => ['description'] } ) };
79
my $ccodes = { map { ( $_->{authorised_value} => $_->{lib} ) } Koha::AuthorisedValues->get_descriptions_by_koha_field( { frameworkcode => '', kohafield => 'items.ccode' }, { order_by => ['description'] } ) };
79
my $ccodes = { map { ( $_->{authorised_value} => $_->{lib} ) } Koha::AuthorisedValues->get_descriptions_by_koha_field( { frameworkcode => '', kohafield => 'items.ccode' }, { order_by => ['description'] } ) };
Lines 330-336 sub display_value { Link Here
330
        }
330
        }
331
    }
331
    }
332
    elsif ( $crit =~ /category/ ) {
332
    elsif ( $crit =~ /category/ ) {
333
        my @patron_categories = Koha::Patron::Categories->search_limited({}, {order_by => ['description']});
333
        my @patron_categories = Koha::Patron::Categories->search_with_library_limits({}, {order_by => ['description']});
334
        foreach my $patron_category ( @patron_categories ) {
334
        foreach my $patron_category ( @patron_categories ) {
335
            ( $value eq $patron_category->categorycode ) or next;
335
            ( $value eq $patron_category->categorycode ) or next;
336
            $display_value = $patron_category->description and last;
336
            $display_value = $patron_category->description and last;
(-)a/serials/add_user_search.pl (-1 / +1 lines)
Lines 43-49 my $op = $input->param('op') || ''; Link Here
43
43
44
my $referer = $input->referer();
44
my $referer = $input->referer();
45
45
46
my $patron_categories = Koha::Patron::Categories->search_limited;
46
my $patron_categories = Koha::Patron::Categories->search_with_library_limits;
47
$template->param(
47
$template->param(
48
    view => ( $input->request_method() eq "GET" ) ? "show_form" : "show_results",
48
    view => ( $input->request_method() eq "GET" ) ? "show_form" : "show_results",
49
    columns => ['cardnumber', 'name', 'branch', 'action'],
49
    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 178-184 elsif ( $step == 3 ) { Link Here
178
    $template->param( patron_lists => [ @non_empty_lists ] );
178
    $template->param( patron_lists => [ @non_empty_lists ] );
179
}
179
}
180
180
181
my $patron_categories = Koha::Patron::Categories->search_limited({}, {order_by => ['description']});
181
my $patron_categories = Koha::Patron::Categories->search_with_library_limits({}, {order_by => ['description']});
182
182
183
$template->param(
183
$template->param(
184
    step                   => $step,
184
    step                   => $step,
(-)a/tools/import_borrowers.pl (-1 / +1 lines)
Lines 77-83 my ( $template, $loggedinuser, $cookie ) = get_template_and_user( Link Here
77
);
77
);
78
78
79
# get the patron categories and pass them to the template
79
# get the patron categories and pass them to the template
80
my @patron_categories = Koha::Patron::Categories->search_limited({}, {order_by => ['description']});
80
my @patron_categories = Koha::Patron::Categories->search_with_library_limits({}, {order_by => ['description']});
81
$template->param( categories => \@patron_categories );
81
$template->param( categories => \@patron_categories );
82
my $columns = C4::Templates::GetColumnDefs( $input )->{borrowers};
82
my $columns = C4::Templates::GetColumnDefs( $input )->{borrowers};
83
$columns = [ grep { $_->{field} ne 'borrowernumber' ? $_ : () } @$columns ];
83
$columns = [ grep { $_->{field} ne 'borrowernumber' ? $_ : () } @$columns ];
(-)a/tools/modborrowers.pl (-2 / +1 lines)
Lines 113-119 if ( $op eq 'show' ) { Link Here
113
    my @patron_attributes_codes;
113
    my @patron_attributes_codes;
114
    my $library_id = C4::Context->userenv ? C4::Context->userenv->{'branch'} : undef;
114
    my $library_id = C4::Context->userenv ? C4::Context->userenv->{'branch'} : undef;
115
    my $patron_attribute_types = Koha::Patron::Attribute::Types->search_with_library_limits({}, {}, $library_id);
115
    my $patron_attribute_types = Koha::Patron::Attribute::Types->search_with_library_limits({}, {}, $library_id);
116
    my @patron_categories = Koha::Patron::Categories->search_limited({}, {order_by => ['description']});
116
    my @patron_categories = Koha::Patron::Categories->search_with_library_limits({}, {order_by => ['description']});
117
    while ( my $attr_type = $patron_attribute_types->next ) {
117
    while ( my $attr_type = $patron_attribute_types->next ) {
118
        # TODO Repeatable attributes are not correctly managed and can cause data lost.
118
        # TODO Repeatable attributes are not correctly managed and can cause data lost.
119
        # This should be implemented.
119
        # This should be implemented.
120
- 

Return to bug 23271