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

(-)a/C4/Members.pm (-27 lines)
Lines 80-86 BEGIN { Link Here
80
80
81
        &GetborCatFromCatType
81
        &GetborCatFromCatType
82
        GetBorrowerCategorycode
82
        GetBorrowerCategorycode
83
        &GetBorrowercategoryList
84
83
85
        &GetBorrowersToExpunge
84
        &GetBorrowersToExpunge
86
        &GetBorrowersWhoHaveNeverBorrowed
85
        &GetBorrowersWhoHaveNeverBorrowed
Lines 1370-1401 sub GetBorrowerCategorycode { Link Here
1370
    return $sth->fetchrow;
1369
    return $sth->fetchrow;
1371
}
1370
}
1372
1371
1373
=head2 GetBorrowercategoryList
1374
1375
  $arrayref_hashref = &GetBorrowercategoryList;
1376
If no category code provided, the function returns all the categories.
1377
1378
=cut
1379
1380
sub GetBorrowercategoryList {
1381
    my $no_branch_limit = @_ ? shift : 0;
1382
    my $branch_limit = $no_branch_limit
1383
        ? 0
1384
        : C4::Context->userenv ? C4::Context->userenv->{"branch"} : "";
1385
    my $dbh       = C4::Context->dbh;
1386
    my $query = "SELECT categories.* FROM categories";
1387
    $query .= qq{
1388
        LEFT JOIN categories_branches ON categories.categorycode = categories_branches.categorycode
1389
        WHERE branchcode = ? OR branchcode IS NULL GROUP BY description
1390
    } if $branch_limit;
1391
    $query .= " ORDER BY description";
1392
    my $sth = $dbh->prepare( $query );
1393
    $sth->execute( $branch_limit ? $branch_limit : () );
1394
    my $data = $sth->fetchall_arrayref( {} );
1395
    $sth->finish;
1396
    return $data;
1397
}    # sub getborrowercategory
1398
1399
=head2 GetAge
1372
=head2 GetAge
1400
1373
1401
  $dateofbirth,$date = &GetAge($date);
1374
  $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
our $itemtypes = GetItemTypes();
78
our $itemtypes = GetItemTypes();
79
our $categoryloop = GetBorrowercategoryList;
79
our @patron_categories = Koha::Patron::Categories->search_limited({}, {order_by => ['description']});
80
80
81
our $ccodes    = GetKohaAuthorisedValues("items.ccode");
81
our $ccodes    = GetKohaAuthorisedValues("items.ccode");
82
our $locations = GetKohaAuthorisedValues("items.location");
82
our $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 86-93 my ( $template, $loggedinuser, $cookie ) = get_template_and_user({ Link Here
86
my $branches = GetBranchesLoop();
86
my $branches = GetBranchesLoop();
87
$template->param( branches => $branches ) if ( $branches );
87
$template->param( branches => $branches ) if ( $branches );
88
# get the patron categories and pass them to the template
88
# get the patron categories and pass them to the template
89
my $categories = GetBorrowercategoryList();
89
my @patron_categories = Koha::Patron::Categories->search_limited({}, {order_by => ['description']});
90
$template->param( categories => $categories ) if ( $categories );
90
$template->param( categories => \@patron_categories );
91
my $columns = C4::Templates::GetColumnDefs( $input )->{borrowers};
91
my $columns = C4::Templates::GetColumnDefs( $input )->{borrowers};
92
$columns = [ grep { $_->{field} ne 'borrowernumber' ? $_ : () } @$columns ];
92
$columns = [ grep { $_->{field} ne 'borrowernumber' ? $_ : () } @$columns ];
93
$template->param( borrower_fields => $columns );
93
$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