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

(-)a/C4/Members.pm (-27 lines)
Lines 81-87 BEGIN { Link Here
81
81
82
        &GetborCatFromCatType
82
        &GetborCatFromCatType
83
        GetBorrowerCategorycode
83
        GetBorrowerCategorycode
84
        &GetBorrowercategoryList
85
84
86
        &GetBorrowersToExpunge
85
        &GetBorrowersToExpunge
87
        &GetBorrowersWhoHaveNeverBorrowed
86
        &GetBorrowersWhoHaveNeverBorrowed
Lines 1473-1504 sub GetBorrowerCategorycode { Link Here
1473
    return $sth->fetchrow;
1472
    return $sth->fetchrow;
1474
}
1473
}
1475
1474
1476
=head2 GetBorrowercategoryList
1477
1478
  $arrayref_hashref = &GetBorrowercategoryList;
1479
If no category code provided, the function returns all the categories.
1480
1481
=cut
1482
1483
sub GetBorrowercategoryList {
1484
    my $no_branch_limit = @_ ? shift : 0;
1485
    my $branch_limit = $no_branch_limit
1486
        ? 0
1487
        : C4::Context->userenv ? C4::Context->userenv->{"branch"} : "";
1488
    my $dbh       = C4::Context->dbh;
1489
    my $query = "SELECT categories.* FROM categories";
1490
    $query .= qq{
1491
        LEFT JOIN categories_branches ON categories.categorycode = categories_branches.categorycode
1492
        WHERE branchcode = ? OR branchcode IS NULL GROUP BY description
1493
    } if $branch_limit;
1494
    $query .= " ORDER BY description";
1495
    my $sth = $dbh->prepare( $query );
1496
    $sth->execute( $branch_limit ? $branch_limit : () );
1497
    my $data = $sth->fetchall_arrayref( {} );
1498
    $sth->finish;
1499
    return $data;
1500
}    # sub getborrowercategory
1501
1502
=head2 GetAge
1475
=head2 GetAge
1503
1476
1504
  $dateofbirth,$date = &GetAge($date);
1477
  $dateofbirth,$date = &GetAge($date);
(-)a/admin/patron-attr-types.pl (-3 / +6 lines)
Lines 29-37 use C4::Branch; Link Here
29
use C4::Context;
29
use C4::Context;
30
use C4::Output;
30
use C4::Output;
31
use C4::Koha;
31
use C4::Koha;
32
use C4::Members qw/GetBorrowercategoryList/;
33
use C4::Members::AttributeTypes;
32
use C4::Members::AttributeTypes;
34
33
34
use Koha::Patron::Categories;
35
35
my $script_name = "/cgi-bin/koha/admin/patron-attr-types.pl";
36
my $script_name = "/cgi-bin/koha/admin/patron-attr-types.pl";
36
37
37
our $input = new CGI;
38
our $input = new CGI;
Lines 92-101 sub add_attribute_type_form { Link Here
92
        };
93
        };
93
    }
94
    }
94
95
96
    my $patron_categories = Koha::Patron::Categories->search_limited({}, {order_by => ['description']});
95
    $template->param(
97
    $template->param(
96
        attribute_type_form => 1,
98
        attribute_type_form => 1,
97
        confirm_op => 'add_attribute_type_confirmed',
99
        confirm_op => 'add_attribute_type_confirmed',
98
        categories => GetBorrowercategoryList,
100
        categories => $patron_categories,
99
        branches_loop => \@branches_loop,
101
        branches_loop => \@branches_loop,
100
    );
102
    );
101
    authorised_value_category_list($template);
103
    authorised_value_category_list($template);
Lines 269-279 sub edit_attribute_type_form { Link Here
269
        category_description => $attr_type->category_description,
271
        category_description => $attr_type->category_description,
270
    );
272
    );
271
273
274
    my @patron_categories = Koha::Patron::Categories->search({}, {order_by => ['description']});
272
    $template->param(
275
    $template->param(
273
        attribute_type_form => 1,
276
        attribute_type_form => 1,
274
        edit_attribute_type => 1,
277
        edit_attribute_type => 1,
275
        confirm_op => 'edit_attribute_type_confirmed',
278
        confirm_op => 'edit_attribute_type_confirmed',
276
        categories => GetBorrowercategoryList,
279
        categories => \@patron_categories,
277
    );
280
    );
278
281
279
}
282
}
(-)a/reports/issues_stats.pl (-14 / +14 lines)
Lines 76-82 $template->param(do_it => $do_it, Link Here
76
);
76
);
77
77
78
my $itemtypes = GetItemTypes();
78
my $itemtypes = GetItemTypes();
79
my $categoryloop = GetBorrowercategoryList;
79
my @patron_categories = Koha::Patron::Categories->search_limited({}, {order_by => ['description']});
80
80
81
my $ccodes    = GetKohaAuthorisedValues("items.ccode");
81
my $ccodes    = GetKohaAuthorisedValues("items.ccode");
82
my $locations = GetKohaAuthorisedValues("items.location");
82
my $locations = GetKohaAuthorisedValues("items.location");
Lines 152-158 my $CGIextChoice = ( 'CSV' ); # FIXME translation Link Here
152
my $CGIsepChoice=GetDelimiterChoices;
152
my $CGIsepChoice=GetDelimiterChoices;
153
 
153
 
154
$template->param(
154
$template->param(
155
	categoryloop => $categoryloop,
155
    categoryloop => \@patron_categories,
156
	itemtypeloop => \@itemtypeloop,
156
	itemtypeloop => \@itemtypeloop,
157
	locationloop => \@locations,
157
	locationloop => \@locations,
158
	   ccodeloop => \@ccodes,
158
	   ccodeloop => \@ccodes,
Lines 322-333 sub calculate { Link Here
322
				($celvalue eq $_->{authorised_value}) or next;
322
				($celvalue eq $_->{authorised_value}) or next;
323
				$cell{rowtitle_display} = $_->{lib} and last;
323
				$cell{rowtitle_display} = $_->{lib} and last;
324
			}
324
			}
325
		} elsif ($line =~ /category/) {
325
        } elsif ($line =~ /category/) {
326
			foreach (@$categoryloop) {
326
            foreach my $patron_category ( @patron_categories ) {
327
				($celvalue eq $_->{categorycode}) or next;
327
                ($celvalue eq $patron_category->categorycode) or next;
328
				$cell{rowtitle_display} = $_->{description} and last;
328
                $cell{rowtitle_display} = $patron_category->description and last;
329
			}
329
            }
330
		}
330
        }
331
		push @loopline, \%cell;
331
		push @loopline, \%cell;
332
	}
332
	}
333
333
Lines 396-407 sub calculate { Link Here
396
				($celvalue eq $_->{authorised_value}) or next;
396
				($celvalue eq $_->{authorised_value}) or next;
397
				$cell{coltitle_display} = $_->{lib} and last;
397
				$cell{coltitle_display} = $_->{lib} and last;
398
			}
398
			}
399
		} elsif ($column =~ /category/) {
399
        } elsif ($column =~ /category/) {
400
			foreach (@$categoryloop) {
400
            foreach my $patron_category ( @patron_categories ) {
401
				($celvalue eq $_->{categorycode}) or next;
401
                ($celvalue eq $patron_category->categorycode) or next;
402
				$cell{coltitle_display} = $_->{description} and last;
402
                $cell{coltitle_display} = $patron_category->description and last;
403
			}
403
            }
404
		}
404
        }
405
		push @loopcol, \%cell;
405
		push @loopcol, \%cell;
406
	}
406
	}
407
407
(-)a/reports/reserves_stats.pl (-5 / +6 lines)
Lines 32-37 use C4::Output; Link Here
32
use C4::Reports;
32
use C4::Reports;
33
use C4::Members;
33
use C4::Members;
34
use Koha::DateUtils;
34
use Koha::DateUtils;
35
use Koha::Patron::Categories;
35
use List::MoreUtils qw/any/;
36
use List::MoreUtils qw/any/;
36
use YAML;
37
use YAML;
37
38
Lines 80-86 $template->param(do_it => $do_it, Link Here
80
);
81
);
81
82
82
my $itemtypes = GetItemTypes();
83
my $itemtypes = GetItemTypes();
83
my $categoryloop = GetBorrowercategoryList;
84
my @patron_categories = Koha::Patron::Categories->search_limited({}, {order_by => ['description']});
84
85
85
my $ccodes    = GetKohaAuthorisedValues("items.ccode");
86
my $ccodes    = GetKohaAuthorisedValues("items.ccode");
86
my $locations = GetKohaAuthorisedValues("items.location");
87
my $locations = GetKohaAuthorisedValues("items.location");
Lines 158-164 my $CGIextChoice = ( 'CSV' ); # FIXME translation Link Here
158
my $CGIsepChoice=GetDelimiterChoices;
159
my $CGIsepChoice=GetDelimiterChoices;
159
 
160
 
160
$template->param(
161
$template->param(
161
	categoryloop => $categoryloop,
162
    categoryloop => \@patron_categories,
162
	itemtypeloop => \@itemtypeloop,
163
	itemtypeloop => \@itemtypeloop,
163
	locationloop => \@locations,
164
	locationloop => \@locations,
164
	   ccodeloop => \@ccodes,
165
	   ccodeloop => \@ccodes,
Lines 353-361 sub display_value { Link Here
353
        }
354
        }
354
    }
355
    }
355
    elsif ( $crit =~ /category/ ) {
356
    elsif ( $crit =~ /category/ ) {
356
        foreach (@$categoryloop) {
357
        foreach my $patron_category ( @patron_categories ) {
357
            ( $value eq $_->{categorycode} ) or next;
358
            ( $value eq $patron_category->categorycode ) or next;
358
            $display_value = $_->{description} and last;
359
            $display_value = $patron_category->description and last;
359
        }
360
        }
360
    }
361
    }
361
    return $display_value;
362
    return $display_value;
(-)a/tools/cleanborrowers.pl (-1 / +4 lines)
Lines 40-45 use C4::Output; Link Here
40
use C4::Members;        # GetBorrowersWhoHavexxxBorrowed.
40
use C4::Members;        # GetBorrowersWhoHavexxxBorrowed.
41
use C4::Circulation;    # AnonymiseIssueHistory.
41
use C4::Circulation;    # AnonymiseIssueHistory.
42
use Koha::DateUtils qw( dt_from_string output_pref );
42
use Koha::DateUtils qw( dt_from_string output_pref );
43
use Koha::Patron::Categories;
43
use Date::Calc qw/Today Add_Delta_YM/;
44
use Date::Calc qw/Today Add_Delta_YM/;
44
use Koha::List::Patron;
45
use Koha::List::Patron;
45
46
Lines 161-172 elsif ( $step == 3 ) { Link Here
161
    $template->param( patron_lists => [ @non_empty_lists ] );
162
    $template->param( patron_lists => [ @non_empty_lists ] );
162
}
163
}
163
164
165
my $patron_categories = Koha::Patron::Categories->search_limited({}, {order_by => ['description']});
166
164
$template->param(
167
$template->param(
165
    step                   => $step,
168
    step                   => $step,
166
    not_borrowed_since   => $not_borrowed_since,
169
    not_borrowed_since   => $not_borrowed_since,
167
    borrower_dateexpiry    => $borrower_dateexpiry,
170
    borrower_dateexpiry    => $borrower_dateexpiry,
168
    last_issue_date        => $last_issue_date,
171
    last_issue_date        => $last_issue_date,
169
    borrower_categorycodes => GetBorrowercategoryList(),
172
    borrower_categorycodes => $patron_categories,
170
    borrower_categorycode  => $borrower_categorycode,
173
    borrower_categorycode  => $borrower_categorycode,
171
);
174
);
172
175
(-)a/tools/import_borrowers.pl (-2 / +2 lines)
Lines 85-92 my ( $template, $loggedinuser, $cookie ) = get_template_and_user({ Link Here
85
my $branches = GetBranchesLoop();
85
my $branches = GetBranchesLoop();
86
$template->param( branches => $branches ) if ( $branches );
86
$template->param( branches => $branches ) if ( $branches );
87
# get the patron categories and pass them to the template
87
# get the patron categories and pass them to the template
88
my $categories = GetBorrowercategoryList();
88
my @patron_categories = Koha::Patron::Categories->search_limited({}, {order_by => ['description']});
89
$template->param( categories => $categories ) if ( $categories );
89
$template->param( categories => \@patron_categories );
90
my $columns = C4::Templates::GetColumnDefs( $input )->{borrowers};
90
my $columns = C4::Templates::GetColumnDefs( $input )->{borrowers};
91
$columns = [ grep { $_->{field} ne 'borrowernumber' ? $_ : () } @$columns ];
91
$columns = [ grep { $_->{field} ne 'borrowernumber' ? $_ : () } @$columns ];
92
$template->param( borrower_fields => $columns );
92
$template->param( borrower_fields => $columns );
(-)a/tools/modborrowers.pl (-6 / +4 lines)
Lines 105-111 if ( $op eq 'show' ) { Link Here
105
    my @patron_attributes_values;
105
    my @patron_attributes_values;
106
    my @patron_attributes_codes;
106
    my @patron_attributes_codes;
107
    my $patron_attribute_types = C4::Members::AttributeTypes::GetAttributeTypes_hashref('all');
107
    my $patron_attribute_types = C4::Members::AttributeTypes::GetAttributeTypes_hashref('all');
108
    my $patron_categories = C4::Members::GetBorrowercategoryList;
108
    my @patron_categories = Koha::Patron::Categories->search_limited({}, {order_by => ['description']});
109
    for ( values %$patron_attribute_types ) {
109
    for ( values %$patron_attribute_types ) {
110
        my $attr_type = C4::Members::AttributeTypes->fetch( $_->{code} );
110
        my $attr_type = C4::Members::AttributeTypes->fetch( $_->{code} );
111
        # TODO Repeatable attributes are not correctly managed and can cause data lost.
111
        # TODO Repeatable attributes are not correctly managed and can cause data lost.
Lines 123-130 if ( $op eq 'show' ) { Link Here
123
123
124
        my $category_code = $_->{category_code};
124
        my $category_code = $_->{category_code};
125
        my ( $category_lib ) = map {
125
        my ( $category_lib ) = map {
126
            ( defined $category_code and $_->{categorycode} eq $category_code ) ? $_->{description} : ()
126
            ( defined $category_code and $_->categorycode eq $category_code ) ? $_->description : ()
127
        } @$patron_categories;
127
        } @patron_categories;
128
        push @patron_attributes_codes,
128
        push @patron_attributes_codes,
129
            {
129
            {
130
                attribute_code => $_->{code},
130
                attribute_code => $_->{code},
Lines 149-157 if ( $op eq 'show' ) { Link Here
149
    my @branches_option;
149
    my @branches_option;
150
    push @branches_option, { value => $_->{value}, lib => $_->{branchname} } for @$branches;
150
    push @branches_option, { value => $_->{value}, lib => $_->{branchname} } for @$branches;
151
    unshift @branches_option, { value => "", lib => "" };
151
    unshift @branches_option, { value => "", lib => "" };
152
    my $categories = GetBorrowercategoryList;
153
    my @categories_option;
152
    my @categories_option;
154
    push @categories_option, { value => $_->{categorycode}, lib => $_->{description} } for @$categories;
153
    push @categories_option, { value => $_->categorycode, lib => $_->description } for @patron_categories;
155
    unshift @categories_option, { value => "", lib => "" };
154
    unshift @categories_option, { value => "", lib => "" };
156
    my $bsort1 = GetAuthorisedValues("Bsort1");
155
    my $bsort1 = GetAuthorisedValues("Bsort1");
157
    my @sort1_option;
156
    my @sort1_option;
158
- 

Return to bug 15407