@@ -, +, @@
GetborCatFromCatType
- Same prerequisite as before
- Add/edit a patron, change his/her patron category value.
- On the 3 following reports:
reports/bor_issues_top.pl
reports/borrowers_out.pl
reports/cat_issues_top.pl
---
C4/Members.pm | 55 -----------------
Koha/Patron/Categories.pm | 16 +++--
circ/circulation.pl | 7 +--
.../prog/en/modules/members/update-child.tt | 69 +++++++++++-----------
.../prog/en/modules/reports/bor_issues_top.tt | 6 +-
.../prog/en/modules/reports/borrowers_out.tt | 6 +-
.../prog/en/modules/reports/cat_issues_top.tt | 6 +-
.../modules/reports/issues_by_borrower_category.tt | 4 +-
members/boraccount.pl | 9 +--
members/mancredit.pl | 9 +--
members/maninvoice.pl | 9 +--
members/member-flags.pl | 9 +--
members/member-password.pl | 9 +--
members/memberentry.pl | 42 +++++++------
members/moremember.pl | 9 ++-
members/pay.pl | 14 ++---
members/paycollect.pl | 14 ++---
members/printfeercpt.pl | 8 +--
members/printinvoice.pl | 9 +--
members/readingrec.pl | 9 +--
members/update-child.pl | 24 +++-----
reports/bor_issues_top.pl | 19 ++----
reports/borrowers_out.pl | 15 ++---
reports/cat_issues_top.pl | 18 ++----
reports/issues_by_borrower_category.plugin | 15 ++---
t/db_dependent/Koha/Patron/Categories.t | 10 +++-
26 files changed, 169 insertions(+), 251 deletions(-)
--- a/C4/Members.pm
+++ a/C4/Members.pm
@@ -87,7 +87,6 @@ BEGIN {
&GetMemberAccountRecords
&GetBorNotifyAcctRecord
- &GetborCatFromCatType
GetBorrowerCategorycode
&GetBorrowersToExpunge
@@ -1508,60 +1507,6 @@ sub GetUpcomingMembershipExpires {
return $results;
}
-=head2 GetborCatFromCatType
-
- ($codes_arrayref, $labels_hashref) = &GetborCatFromCatType();
-
-Looks up the different types of borrowers in the database. Returns two
-elements: a reference-to-array, which lists the borrower category
-codes, and a reference-to-hash, which maps the borrower category codes
-to category descriptions.
-
-=cut
-
-#'
-sub GetborCatFromCatType {
- my ( $category_type, $action, $no_branch_limit ) = @_;
-
- my $branch_limit = $no_branch_limit
- ? 0
- : C4::Context->userenv ? C4::Context->userenv->{"branch"} : "";
-
- # FIXME - This API seems both limited and dangerous.
- my $dbh = C4::Context->dbh;
-
- my $request = qq{
- SELECT categories.categorycode, categories.description
- FROM categories
- };
- $request .= qq{
- LEFT JOIN categories_branches ON categories.categorycode = categories_branches.categorycode
- } if $branch_limit;
- if($action) {
- $request .= " $action ";
- $request .= " AND (branchcode = ? OR branchcode IS NULL) GROUP BY description" if $branch_limit;
- } else {
- $request .= " WHERE branchcode = ? OR branchcode IS NULL GROUP BY description" if $branch_limit;
- }
- $request .= " ORDER BY categorycode";
-
- my $sth = $dbh->prepare($request);
- $sth->execute(
- $action ? $category_type : (),
- $branch_limit ? $branch_limit : ()
- );
-
- my %labels;
- my @codes;
-
- while ( my $data = $sth->fetchrow_hashref ) {
- push @codes, $data->{'categorycode'};
- $labels{ $data->{'categorycode'} } = $data->{'description'};
- }
- $sth->finish;
- return ( \@codes, \%labels );
-}
-
=head2 GetBorrowerCategorycode
$categorycode = &GetBorrowerCategoryCode( $borrowernumber );
--- a/Koha/Patron/Categories.pm
+++ a/Koha/Patron/Categories.pm
@@ -38,16 +38,14 @@ Koha::Patron::Categories - Koha Patron Category Object set class
=cut
sub search_limited {
- my ( $self ) = @_;
+ my ( $self, $params, $attributes ) = @_;
my $branch_limit = C4::Context->userenv ? C4::Context->userenv->{"branch"} : "";
- return $self->search({}, {order_by => ['description']}) unless $branch_limit;
- return $self->search({
- 'categories_branches.branchcode' => [$branch_limit, undef]},
- {
- join => 'categories_branches',
- order_by => ['description'],
- }
- );
+ if ( $branch_limit ) {
+ $params->{'categories_branches.branchcode'} = [ $branch_limit, undef ];
+ $attributes->{join} = 'categories_branches';
+ }
+ $attributes->{order_by} = ['description'] unless $attributes->{order_by};
+ return $self->search($params, $attributes);
}
=head3 type
--- a/circ/circulation.pl
+++ a/circ/circulation.pl
@@ -541,10 +541,9 @@ $amountold =~ s/^.*\$//; # remove upto the $, if any
my ( $total, $accts, $numaccts) = GetMemberAccountRecords( $borrowernumber );
if ( $borrowernumber && $borrower->{'category_type'} eq 'C') {
- my ( $catcodes, $labels ) = GetborCatFromCatType( 'A', 'WHERE category_type = ?' );
- my $cnt = scalar(@$catcodes);
- $template->param( 'CATCODE_MULTI' => 1) if $cnt > 1;
- $template->param( 'catcode' => $catcodes->[0]) if $cnt == 1;
+ my $patron_categories = Koha::Patron::Categories->search_limited({ category_type => 'A' }, {order_by => ['categorycode']});
+ $template->param( 'CATCODE_MULTI' => 1) if $patron_categories->count > 1;
+ $template->param( 'catcode' => $patron_categories->next ) if $patron_categories->count == 1;
}
my $lib_messages_loop = GetMessages( $borrowernumber, 'L', $branch );
--- a/koha-tmpl/intranet-tmpl/prog/en/modules/members/update-child.tt
+++ a/koha-tmpl/intranet-tmpl/prog/en/modules/members/update-child.tt
@@ -49,40 +49,43 @@ window.close();
[% IF ( MULTI ) %]
-
Choose Adult category
+ Choose Adult category
-[% IF ( CAT_LOOP ) %]
-
-
+ [% IF patron_categories %]
+
+ [% END %]
[% END %]
--- a/koha-tmpl/intranet-tmpl/prog/en/modules/reports/bor_issues_top.tt
+++ a/koha-tmpl/intranet-tmpl/prog/en/modules/reports/bor_issues_top.tt
@@ -154,9 +154,9 @@ function Dopop(link) {
--- a/koha-tmpl/intranet-tmpl/prog/en/modules/reports/borrowers_out.tt
+++ a/koha-tmpl/intranet-tmpl/prog/en/modules/reports/borrowers_out.tt
@@ -60,9 +60,9 @@ $(document).ready(function(){