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 1583-1614 sub GetBorrowerCategorycode { Link Here
1583
    return $sth->fetchrow;
1582
    return $sth->fetchrow;
1584
}
1583
}
1585
1584
1586
=head2 GetBorrowercategoryList
1587
1588
  $arrayref_hashref = &GetBorrowercategoryList;
1589
If no category code provided, the function returns all the categories.
1590
1591
=cut
1592
1593
sub GetBorrowercategoryList {
1594
    my $no_branch_limit = @_ ? shift : 0;
1595
    my $branch_limit = $no_branch_limit
1596
        ? 0
1597
        : C4::Context->userenv ? C4::Context->userenv->{"branch"} : "";
1598
    my $dbh       = C4::Context->dbh;
1599
    my $query = "SELECT categories.* FROM categories";
1600
    $query .= qq{
1601
        LEFT JOIN categories_branches ON categories.categorycode = categories_branches.categorycode
1602
        WHERE branchcode = ? OR branchcode IS NULL GROUP BY description
1603
    } if $branch_limit;
1604
    $query .= " ORDER BY description";
1605
    my $sth = $dbh->prepare( $query );
1606
    $sth->execute( $branch_limit ? $branch_limit : () );
1607
    my $data = $sth->fetchall_arrayref( {} );
1608
    $sth->finish;
1609
    return $data;
1610
}    # sub getborrowercategory
1611
1612
=head2 GetAge
1585
=head2 GetAge
1613
1586
1614
  $dateofbirth,$date = &GetAge($date);
1587
  $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({}, {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({}, {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({}, {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({}, {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({}, {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 104-110 if ( $op eq 'show' ) { Link Here
104
    my @patron_attributes_values;
104
    my @patron_attributes_values;
105
    my @patron_attributes_codes;
105
    my @patron_attributes_codes;
106
    my $patron_attribute_types = C4::Members::AttributeTypes::GetAttributeTypes_hashref('all');
106
    my $patron_attribute_types = C4::Members::AttributeTypes::GetAttributeTypes_hashref('all');
107
    my $patron_categories = C4::Members::GetBorrowercategoryList;
107
    my @patron_categories = Koha::Patron::Categories->search({}, {order_by => ['description']});
108
    for ( values %$patron_attribute_types ) {
108
    for ( values %$patron_attribute_types ) {
109
        my $attr_type = C4::Members::AttributeTypes->fetch( $_->{code} );
109
        my $attr_type = C4::Members::AttributeTypes->fetch( $_->{code} );
110
        my $options = $attr_type->authorised_value_category
110
        my $options = $attr_type->authorised_value_category
Lines 118-125 if ( $op eq 'show' ) { Link Here
118
118
119
        my $category_code = $_->{category_code};
119
        my $category_code = $_->{category_code};
120
        my ( $category_lib ) = map {
120
        my ( $category_lib ) = map {
121
            ( defined $category_code and $_->{categorycode} eq $category_code ) ? $_->{description} : ()
121
            ( defined $category_code and $_->categorycode eq $category_code ) ? $_->description : ()
122
        } @$patron_categories;
122
        } @patron_categories;
123
        push @patron_attributes_codes,
123
        push @patron_attributes_codes,
124
            {
124
            {
125
                attribute_code => $_->{code},
125
                attribute_code => $_->{code},
Lines 144-152 if ( $op eq 'show' ) { Link Here
144
    my @branches_option;
144
    my @branches_option;
145
    push @branches_option, { value => $_->{value}, lib => $_->{branchname} } for @$branches;
145
    push @branches_option, { value => $_->{value}, lib => $_->{branchname} } for @$branches;
146
    unshift @branches_option, { value => "", lib => "" };
146
    unshift @branches_option, { value => "", lib => "" };
147
    my $categories = GetBorrowercategoryList;
148
    my @categories_option;
147
    my @categories_option;
149
    push @categories_option, { value => $_->{categorycode}, lib => $_->{description} } for @$categories;
148
    push @categories_option, { value => $_->categorycode, lib => $_->description } for @patron_categories;
150
    unshift @categories_option, { value => "", lib => "" };
149
    unshift @categories_option, { value => "", lib => "" };
151
    my $bsort1 = GetAuthorisedValues("Bsort1");
150
    my $bsort1 = GetAuthorisedValues("Bsort1");
152
    my @sort1_option;
151
    my @sort1_option;
153
- 

Return to bug 15407