Bugzilla – Attachment 54363 Details for
Bug 15407
Move the patron categories related code to Koha::Patron::Categories - part 2
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 15407: Koha::Patron::Categories - replace GetBorrowercategory
Bug-15407-KohaPatronCategories---replace-GetBorrow.patch (text/plain), 9.33 KB, created by
Marcel de Rooy
on 2016-08-12 11:45:48 UTC
(
hide
)
Description:
Bug 15407: Koha::Patron::Categories - replace GetBorrowercategory
Filename:
MIME Type:
Creator:
Marcel de Rooy
Created:
2016-08-12 11:45:48 UTC
Size:
9.33 KB
patch
obsolete
>From 0e348a7793c7538284433967534c8d1bb285ccb3 Mon Sep 17 00:00:00 2001 >From: Jonathan Druart <jonathan.druart@bugs.koha-community.org> >Date: Mon, 21 Dec 2015 17:13:12 +0000 >Subject: [PATCH] Bug 15407: Koha::Patron::Categories - replace > GetBorrowercategory >Content-Type: text/plain; charset=utf-8 > >The purpose of C4::Members::GetBorrowercategory was to return the patron >category for a given categorycode. This can be done easily with the >Koha::Patron::Categories->find method. > >Test plan: >- Same prerequisite as before >- Edit a guarantor and confirm the information will be updated for his/her > guarantee(s). >- Update a child to adult patron (Note: Should not we hide the patron > categories limited to others libraries? If yes, it must be done on another > bug report). > There is a special behavior if there is only 1 adult category, the > user does not need to select a category. So the same as before with > only 1 adult patron category. >- Import a patron with a category_code which does not exist. You should > be warned. >- Modify some patron using the batch patron modification tool. The > patron category descriptions should correctly be displayed. > >Note that the overduerules page has already been tested in a previous >patch. > >Signed-off-by: Chris Cormack <chris@bigballofwax.co.nz> > >Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl> >--- > C4/Members.pm | 29 ----------------------------- > members/memberentry.pl | 11 ++++++----- > members/update-child.pl | 11 ++++++----- > t/db_dependent/Reserves.t | 3 ++- > tools/import_borrowers.pl | 3 ++- > tools/modborrowers.pl | 3 ++- > tools/overduerules.pl | 4 ++-- > 7 files changed, 20 insertions(+), 44 deletions(-) > >diff --git a/C4/Members.pm b/C4/Members.pm >index 061172f..bb17796 100644 >--- a/C4/Members.pm >+++ b/C4/Members.pm >@@ -79,7 +79,6 @@ BEGIN { > &GetBorNotifyAcctRecord > > &GetborCatFromCatType >- &GetBorrowercategory > GetBorrowerCategorycode > &GetBorrowercategoryList > >@@ -1351,34 +1350,6 @@ sub GetborCatFromCatType { > return ( \@codes, \%labels ); > } > >-=head2 GetBorrowercategory >- >- $hashref = &GetBorrowercategory($categorycode); >- >-Given the borrower's category code, the function returns the corresponding >-data hashref for a comprehensive information display. >- >-=cut >- >-sub GetBorrowercategory { >- my ($catcode) = @_; >- my $dbh = C4::Context->dbh; >- if ($catcode){ >- my $sth = >- $dbh->prepare( >- "SELECT description,dateofbirthrequired,upperagelimit,category_type >- FROM categories >- WHERE categorycode = ?" >- ); >- $sth->execute($catcode); >- my $data = >- $sth->fetchrow_hashref; >- return $data; >- } >- return; >-} # sub getborrowercategory >- >- > =head2 GetBorrowerCategorycode > > $categorycode = &GetBorrowerCategoryCode( $borrowernumber ); >diff --git a/members/memberentry.pl b/members/memberentry.pl >index 413db97..5aa0b4a 100755 >--- a/members/memberentry.pl >+++ b/members/memberentry.pl >@@ -42,6 +42,7 @@ use C4::Form::MessagingPreferences; > use Koha::Patron::Debarments; > use Koha::Cities; > use Koha::DateUtils; >+use Koha::Patron::Categories; > use Koha::Token; > use Email::Valid; > use Module::Load; >@@ -153,9 +154,9 @@ $template->param( "checked" => 1 ) if ( defined($nodouble) && $nodouble eq 1 ); > my $categorycode = $input->param('categorycode') || $borrower_data->{'categorycode'}; > my $category_type = $input->param('category_type') || ''; > unless ($category_type or !($categorycode)){ >- my $borrowercategory = GetBorrowercategory($categorycode); >- $category_type = $borrowercategory->{'category_type'}; >- my $category_name = $borrowercategory->{'description'}; >+ my $borrowercategory = Koha::Patron::Categories->find($categorycode); >+ $category_type = $borrowercategory->category_type; >+ my $category_name = $borrowercategory->description; > $template->param("categoryname"=>$category_name); > } > $category_type="A" unless $category_type; # FIXME we should display a error message instead of a 500 error ! >@@ -303,8 +304,8 @@ if ($op eq 'save' || $op eq 'insert'){ > > if ( $newdata{dateofbirth} ) { > my $age = GetAge($newdata{dateofbirth}); >- my $borrowercategory=GetBorrowercategory($newdata{'categorycode'}); >- my ($low,$high) = ($borrowercategory->{'dateofbirthrequired'}, $borrowercategory->{'upperagelimit'}); >+ my $borrowercategory = Koha::Patron::Categories->find($newdata{categorycode}); >+ my ($low,$high) = ($borrowercategory->dateofbirthrequired, $borrowercategory->upperagelimit); > if (($high && ($age > $high)) or ($age < $low)) { > push @errors, 'ERROR_age_limitations'; > $template->param( age_low => $low); >diff --git a/members/update-child.pl b/members/update-child.pl >index e5e2302..b0a5154 100755 >--- a/members/update-child.pl >+++ b/members/update-child.pl >@@ -33,6 +33,7 @@ use C4::Context; > use C4::Auth; > use C4::Output; > use C4::Members; >+use Koha::Patron::Categories; > > # use Smart::Comments; > >@@ -66,8 +67,8 @@ if ( $op eq 'multi' ) { > my $row; > $row->{catcode} = $k; > $row->{catdesc} = $labels->{$k}; >- my $borcat = GetBorrowercategory( $row->{catcode} ); >- $row->{cattype} = $borcat->{'category_type'}; >+ my $borcat = Koha::Patron::Categories->find($row->{catcode}); >+ $row->{cattype} = $borcat->category_type; > push @rows, $row; > } > $template->param( >@@ -83,9 +84,9 @@ elsif ( $op eq 'update' ) { > my $member = GetMember('borrowernumber'=>$borrowernumber); > $member->{'guarantorid'} = 0; > $member->{'categorycode'} = $catcode; >- my $borcat = GetBorrowercategory($catcode); >- $member->{'category_type'} = $borcat->{'category_type'}; >- $member->{'description'} = $borcat->{'description'}; >+ my $borcat = Koha::Patron::Categories->find($catcode); >+ $member->{'category_type'} = $borcat->category_type; >+ $member->{'description'} = $borcat->description; > delete $member->{password}; > ModMember(%$member); > >diff --git a/t/db_dependent/Reserves.t b/t/db_dependent/Reserves.t >index 1852ae6..699f8d1 100755 >--- a/t/db_dependent/Reserves.t >+++ b/t/db_dependent/Reserves.t >@@ -32,6 +32,7 @@ use Koha::Holds; > use t::lib::Mocks; > > use Koha::DateUtils; >+use Koha::Patron::Categories; > > use Data::Dumper; > BEGIN { >@@ -61,7 +62,7 @@ foreach my $addbra ('CPL', 'FPL', 'RPL') { > > # Add categories if not existing > foreach my $addcat ('S', 'PT') { >- $dbh->do("INSERT INTO categories (categorycode,hidelostitems,category_type) VALUES (?,?,?)",undef,($addcat, 0, $addcat eq 'S'? 'S': 'A')) unless GetBorrowercategory($addcat); >+ $dbh->do("INSERT INTO categories (categorycode,hidelostitems,category_type) VALUES (?,?,?)",undef,($addcat, 0, $addcat eq 'S'? 'S': 'A')) unless Koha::Patron::Categories->find($addcat); > } > > # Create a helper biblio >diff --git a/tools/import_borrowers.pl b/tools/import_borrowers.pl >index e1754e6..e8feaf6 100755 >--- a/tools/import_borrowers.pl >+++ b/tools/import_borrowers.pl >@@ -50,6 +50,7 @@ use C4::Templates; > use Koha::Patron::Debarments; > use Koha::Patrons; > use Koha::DateUtils; >+use Koha::Patron::Categories; > > use Text::CSV; > # Text::CSV::Unicode, even in binary mode, fails to parse lines with these diacriticals: >@@ -179,7 +180,7 @@ if ( $uploadborrowers && length($uploadborrowers) > 0 ) { > #warn join(':',%borrower); > if ($borrower{categorycode}) { > push @missing_criticals, {key=>'categorycode', line=>$. , lineraw=>$borrowerline, value=>$borrower{categorycode}, category_map=>1} >- unless GetBorrowercategory($borrower{categorycode}); >+ unless Koha::Patron::Categories->find($borrower{categorycode}); > } else { > push @missing_criticals, {key=>'categorycode', line=>$. , lineraw=>$borrowerline}; > } >diff --git a/tools/modborrowers.pl b/tools/modborrowers.pl >index 6416343..f165440 100755 >--- a/tools/modborrowers.pl >+++ b/tools/modborrowers.pl >@@ -37,6 +37,7 @@ use C4::Output; > use List::MoreUtils qw /any uniq/; > use Koha::DateUtils qw( dt_from_string ); > use Koha::List::Patron; >+use Koha::Patron::Categories; > > my $input = new CGI; > my $op = $input->param('op') || 'show_form'; >@@ -377,7 +378,7 @@ sub GetBorrowerInfos { > } > $borrower->{$_} = $userdate || ''; > } >- $borrower->{category_description} = GetBorrowercategory( $borrower->{categorycode} )->{description}; >+ $borrower->{category_description} = Koha::Patron::Categories->find( $borrower->{categorycode} )->{description}; > my $attr_loop = C4::Members::Attributes::GetBorrowerAttributes( $borrower->{borrowernumber} ); > $borrower->{patron_attributes} = $attr_loop; > } >diff --git a/tools/overduerules.pl b/tools/overduerules.pl >index d77a6ad..8ce3f3c 100755 >--- a/tools/overduerules.pl >+++ b/tools/overduerules.pl >@@ -129,8 +129,8 @@ if ($op eq 'save') { > > foreach my $bor (keys %temphash){ > # get category name if we need it for an error message >- my $bor_category = GetBorrowercategory($bor); >- my $bor_category_name = defined($bor_category) ? $bor_category->{description} : $bor; >+ my $bor_category = Koha::Patron::Categories->find($bor); >+ my $bor_category_name = $bor_category ? $bor_category->description : $bor; > > # Do some Checking here : delay1 < delay2 <delay3 all of them being numbers > # Raise error if not true >-- >1.7.10.4
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 15407
:
45906
|
45907
|
45908
|
45909
|
45910
|
45913
|
45914
|
47098
|
47099
|
47100
|
47101
|
47102
|
47646
|
47647
|
47648
|
47649
|
47650
|
47754
|
47755
|
47756
|
47757
|
47758
|
50170
|
50171
|
50172
|
50173
|
50174
|
52013
|
52014
|
52015
|
52032
|
52033
|
52034
|
52035
|
52036
|
53419
|
53420
|
53421
|
53422
|
53423
|
53892
|
54342
|
54343
|
54344
|
54345
|
54346
|
54352
|
54353
|
54355
|
54361
|
54362
| 54363 |
54364
|
54365
|
54366
|
54367
|
54368
|
54369
|
54371
|
55517