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

(-)a/C4/Members.pm (-27 lines)
Lines 89-95 BEGIN { Link Here
89
89
90
        &GetborCatFromCatType
90
        &GetborCatFromCatType
91
        GetBorrowerCategorycode
91
        GetBorrowerCategorycode
92
        &GetBorrowercategoryList
93
92
94
        &GetBorrowersToExpunge
93
        &GetBorrowersToExpunge
95
        &GetBorrowersWhoHaveNeverBorrowed
94
        &GetBorrowersWhoHaveNeverBorrowed
Lines 1572-1603 sub GetBorrowerCategorycode { Link Here
1572
    return $sth->fetchrow;
1571
    return $sth->fetchrow;
1573
}
1572
}
1574
1573
1575
=head2 GetBorrowercategoryList
1576
1577
  $arrayref_hashref = &GetBorrowercategoryList;
1578
If no category code provided, the function returns all the categories.
1579
1580
=cut
1581
1582
sub GetBorrowercategoryList {
1583
    my $no_branch_limit = @_ ? shift : 0;
1584
    my $branch_limit = $no_branch_limit
1585
        ? 0
1586
        : C4::Context->userenv ? C4::Context->userenv->{"branch"} : "";
1587
    my $dbh       = C4::Context->dbh;
1588
    my $query = "SELECT categories.* FROM categories";
1589
    $query .= qq{
1590
        LEFT JOIN categories_branches ON categories.categorycode = categories_branches.categorycode
1591
        WHERE branchcode = ? OR branchcode IS NULL GROUP BY description
1592
    } if $branch_limit;
1593
    $query .= " ORDER BY description";
1594
    my $sth = $dbh->prepare( $query );
1595
    $sth->execute( $branch_limit ? $branch_limit : () );
1596
    my $data = $sth->fetchall_arrayref( {} );
1597
    $sth->finish;
1598
    return $data;
1599
}    # sub getborrowercategory
1600
1601
=head2 GetAge
1574
=head2 GetAge
1602
1575
1603
  $dateofbirth,$date = &GetAge($date);
1576
  $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 274-284 sub edit_attribute_type_form { Link Here
274
    $template->param ( category_code => $attr_type->category_code );
276
    $template->param ( category_code => $attr_type->category_code );
275
    $template->param ( category_description => $attr_type->category_description );
277
    $template->param ( category_description => $attr_type->category_description );
276
278
279
    my @patron_categories = Koha::Patron::Categories->search({}, {order_by => ['description']});
277
    $template->param(
280
    $template->param(
278
        attribute_type_form => 1,
281
        attribute_type_form => 1,
279
        edit_attribute_type => 1,
282
        edit_attribute_type => 1,
280
        confirm_op => 'edit_attribute_type_confirmed',
283
        confirm_op => 'edit_attribute_type_confirmed',
281
        categories => GetBorrowercategoryList,
284
        categories => \@patron_categories,
282
    );
285
    );
283
286
284
}
287
}
(-)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
45
45
my $cgi = new CGI;
46
my $cgi = new CGI;
Lines 147-158 elsif ( $step == 3 ) { Link Here
147
    );
148
    );
148
}
149
}
149
150
151
my $patron_categories = Koha::Patron::Categories->search_limited({}, {order_by => ['description']});
152
150
$template->param(
153
$template->param(
151
    step                   => $step,
154
    step                   => $step,
152
    not_borrowered_since   => $not_borrowered_since,
155
    not_borrowered_since   => $not_borrowered_since,
153
    borrower_dateexpiry    => $borrower_dateexpiry,
156
    borrower_dateexpiry    => $borrower_dateexpiry,
154
    last_issue_date        => $last_issue_date,
157
    last_issue_date        => $last_issue_date,
155
    borrower_categorycodes => GetBorrowercategoryList(),
158
    borrower_categorycodes => $patron_categories,
156
    borrower_categorycode  => $borrower_categorycode,
159
    borrower_categorycode  => $borrower_categorycode,
157
);
160
);
158
161
(-)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 122-129 if ( $op eq 'show' ) { Link Here
122
122
123
        my $category_code = $_->{category_code};
123
        my $category_code = $_->{category_code};
124
        my ( $category_lib ) = map {
124
        my ( $category_lib ) = map {
125
            ( defined $category_code and $_->{categorycode} eq $category_code ) ? $_->{description} : ()
125
            ( defined $category_code and $_->categorycode eq $category_code ) ? $_->description : ()
126
        } @$patron_categories;
126
        } @patron_categories;
127
        push @patron_attributes_codes,
127
        push @patron_attributes_codes,
128
            {
128
            {
129
                attribute_code => $_->{code},
129
                attribute_code => $_->{code},
Lines 148-156 if ( $op eq 'show' ) { Link Here
148
    my @branches_option;
148
    my @branches_option;
149
    push @branches_option, { value => $_->{value}, lib => $_->{branchname} } for @$branches;
149
    push @branches_option, { value => $_->{value}, lib => $_->{branchname} } for @$branches;
150
    unshift @branches_option, { value => "", lib => "" };
150
    unshift @branches_option, { value => "", lib => "" };
151
    my $categories = GetBorrowercategoryList;
152
    my @categories_option;
151
    my @categories_option;
153
    push @categories_option, { value => $_->{categorycode}, lib => $_->{description} } for @$categories;
152
    push @categories_option, { value => $_->categorycode, lib => $_->description } for @patron_categories;
154
    unshift @categories_option, { value => "", lib => "" };
153
    unshift @categories_option, { value => "", lib => "" };
155
    my $bsort1 = GetAuthorisedValues("Bsort1");
154
    my $bsort1 = GetAuthorisedValues("Bsort1");
156
    my @sort1_option;
155
    my @sort1_option;
157
- 

Return to bug 15407