&GetborCatFromCatType
GetBorrowerCategorycode
- &GetBorrowercategoryList
&GetBorrowersToExpunge
&GetBorrowersWhoHaveNeverBorrowed
return $sth->fetchrow;
}
-=head2 GetBorrowercategoryList
-
- $arrayref_hashref = &GetBorrowercategoryList;
-If no category code provided, the function returns all the categories.
-
-=cut
-
-sub GetBorrowercategoryList {
- my $no_branch_limit = @_ ? shift : 0;
- my $branch_limit = $no_branch_limit
- ? 0
- : C4::Context->userenv ? C4::Context->userenv->{"branch"} : "";
- my $dbh = C4::Context->dbh;
- my $query = "SELECT categories.* FROM categories";
- $query .= qq{
- LEFT JOIN categories_branches ON categories.categorycode = categories_branches.categorycode
- WHERE branchcode = ? OR branchcode IS NULL GROUP BY description
- } if $branch_limit;
- $query .= " ORDER BY description";
- my $sth = $dbh->prepare( $query );
- $sth->execute( $branch_limit ? $branch_limit : () );
- my $data = $sth->fetchall_arrayref( {} );
- $sth->finish;
- return $data;
-} # sub getborrowercategory
-
=head2 GetAge
$dateofbirth,$date = &GetAge($date);
use C4::Context;
use C4::Output;
use C4::Koha;
-use C4::Members qw/GetBorrowercategoryList/;
use C4::Members::AttributeTypes;
+use Koha::Patron::Categories;
+
my $script_name = "/cgi-bin/koha/admin/patron-attr-types.pl";
our $input = new CGI;
};
}
+ my $patron_categories = Koha::Patron::Categories->search_limited({}, {order_by => ['description']});
$template->param(
attribute_type_form => 1,
confirm_op => 'add_attribute_type_confirmed',
- categories => GetBorrowercategoryList,
+ categories => $patron_categories,
branches_loop => \@branches_loop,
);
authorised_value_category_list($template);
category_description => $attr_type->category_description,
);
+ my @patron_categories = Koha::Patron::Categories->search({}, {order_by => ['description']});
$template->param(
attribute_type_form => 1,
edit_attribute_type => 1,
confirm_op => 'edit_attribute_type_confirmed',
- categories => GetBorrowercategoryList,
+ categories => \@patron_categories,
);
}
);
our $itemtypes = GetItemTypes();
-our $categoryloop = GetBorrowercategoryList;
+our @patron_categories = Koha::Patron::Categories->search_limited({}, {order_by => ['description']});
our $ccodes = GetKohaAuthorisedValues("items.ccode");
our $locations = GetKohaAuthorisedValues("items.location");
my $CGIsepChoice=GetDelimiterChoices;
$template->param(
- categoryloop => $categoryloop,
+ categoryloop => \@patron_categories,
itemtypeloop => \@itemtypeloop,
locationloop => \@locations,
ccodeloop => \@ccodes,
($celvalue eq $_->{authorised_value}) or next;
$cell{rowtitle_display} = $_->{lib} and last;
}
- } elsif ($line =~ /category/) {
- foreach (@$categoryloop) {
- ($celvalue eq $_->{categorycode}) or next;
- $cell{rowtitle_display} = $_->{description} and last;
- }
- }
+ } elsif ($line =~ /category/) {
+ foreach my $patron_category ( @patron_categories ) {
+ ($celvalue eq $patron_category->categorycode) or next;
+ $cell{rowtitle_display} = $patron_category->description and last;
+ }
+ }
push @loopline, \%cell;
}
($celvalue eq $_->{authorised_value}) or next;
$cell{coltitle_display} = $_->{lib} and last;
}
- } elsif ($column =~ /category/) {
- foreach (@$categoryloop) {
- ($celvalue eq $_->{categorycode}) or next;
- $cell{coltitle_display} = $_->{description} and last;
- }
- }
+ } elsif ($column =~ /category/) {
+ foreach my $patron_category ( @patron_categories ) {
+ ($celvalue eq $patron_category->categorycode) or next;
+ $cell{coltitle_display} = $patron_category->description and last;
+ }
+ }
push @loopcol, \%cell;
}
use C4::Reports;
use C4::Members;
use Koha::DateUtils;
+use Koha::Patron::Categories;
use List::MoreUtils qw/any/;
use YAML;
);
my $itemtypes = GetItemTypes();
-my $categoryloop = GetBorrowercategoryList;
+my @patron_categories = Koha::Patron::Categories->search_limited({}, {order_by => ['description']});
my $ccodes = GetKohaAuthorisedValues("items.ccode");
my $locations = GetKohaAuthorisedValues("items.location");
my $CGIsepChoice=GetDelimiterChoices;
$template->param(
- categoryloop => $categoryloop,
+ categoryloop => \@patron_categories,
itemtypeloop => \@itemtypeloop,
locationloop => \@locations,
ccodeloop => \@ccodes,
}
}
elsif ( $crit =~ /category/ ) {
- foreach (@$categoryloop) {
- ( $value eq $_->{categorycode} ) or next;
- $display_value = $_->{description} and last;
+ foreach my $patron_category ( @patron_categories ) {
+ ( $value eq $patron_category->categorycode ) or next;
+ $display_value = $patron_category->description and last;
}
}
return $display_value;
use C4::Members; # GetBorrowersWhoHavexxxBorrowed.
use C4::Circulation; # AnonymiseIssueHistory.
use Koha::DateUtils qw( dt_from_string output_pref );
+use Koha::Patron::Categories;
use Date::Calc qw/Today Add_Delta_YM/;
use Koha::List::Patron;
$template->param( patron_lists => [ @non_empty_lists ] );
}
+my $patron_categories = Koha::Patron::Categories->search_limited({}, {order_by => ['description']});
+
$template->param(
step => $step,
not_borrowed_since => $not_borrowed_since,
borrower_dateexpiry => $borrower_dateexpiry,
last_issue_date => $last_issue_date,
- borrower_categorycodes => GetBorrowercategoryList(),
+ borrower_categorycodes => $patron_categories,
borrower_categorycode => $borrower_categorycode,
);
my $branches = GetBranchesLoop();
$template->param( branches => $branches ) if ( $branches );
# get the patron categories and pass them to the template
-my $categories = GetBorrowercategoryList();
-$template->param( categories => $categories ) if ( $categories );
+my @patron_categories = Koha::Patron::Categories->search_limited({}, {order_by => ['description']});
+$template->param( categories => \@patron_categories );
my $columns = C4::Templates::GetColumnDefs( $input )->{borrowers};
$columns = [ grep { $_->{field} ne 'borrowernumber' ? $_ : () } @$columns ];
$template->param( borrower_fields => $columns );
my @patron_attributes_values;
my @patron_attributes_codes;
my $patron_attribute_types = C4::Members::AttributeTypes::GetAttributeTypes_hashref('all');
- my $patron_categories = C4::Members::GetBorrowercategoryList;
+ my @patron_categories = Koha::Patron::Categories->search_limited({}, {order_by => ['description']});
for ( values %$patron_attribute_types ) {
my $attr_type = C4::Members::AttributeTypes->fetch( $_->{code} );
# TODO Repeatable attributes are not correctly managed and can cause data lost.
my $category_code = $_->{category_code};
my ( $category_lib ) = map {
- ( defined $category_code and $_->{categorycode} eq $category_code ) ? $_->{description} : ()
- } @$patron_categories;
+ ( defined $category_code and $_->categorycode eq $category_code ) ? $_->description : ()
+ } @patron_categories;
push @patron_attributes_codes,
{
attribute_code => $_->{code},
my @branches_option;
push @branches_option, { value => $_->{value}, lib => $_->{branchname} } for @$branches;
unshift @branches_option, { value => "", lib => "" };
- my $categories = GetBorrowercategoryList;
my @categories_option;
- push @categories_option, { value => $_->{categorycode}, lib => $_->{description} } for @$categories;
+ push @categories_option, { value => $_->categorycode, lib => $_->description } for @patron_categories;
unshift @categories_option, { value => "", lib => "" };
my $bsort1 = GetAuthorisedValues("Bsort1");
my @sort1_option;