Bug 18789: Use Koha::Patron->is_adult where needed
authorJonathan Druart <jonathan.druart@bugs.koha-community.org>
Thu, 1 Jun 2017 16:57:12 +0000 (13:57 -0300)
committerJonathan Druart <jonathan.druart@bugs.koha-community.org>
Fri, 16 Feb 2018 16:03:58 +0000 (13:03 -0300)
Test plan:
When editing adult's info you must see the "Add child" button

Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>

Signed-off-by: Josef Moravec <josef.moravec@gmail.com>

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>

17 files changed:
circ/circulation.pl
koha-tmpl/intranet-tmpl/prog/en/includes/members-toolbar.inc
members/boraccount.pl
members/deletemem.pl
members/files.pl
members/housebound.pl
members/mancredit.pl
members/maninvoice.pl
members/member-flags.pl
members/member-password.pl
members/moremember.pl
members/notices.pl
members/printfeercpt.pl
members/printinvoice.pl
members/readingrec.pl
members/routing-lists.pl
members/statistics.pl

index 4ce738c..a64844e 100755 (executable)
@@ -466,9 +466,6 @@ if ($patron) {
         holds_count  => $holds->count(),
         WaitingHolds => $waiting_holds,
     );
-
-    my $category_type = $patron->category->category_type;
-    $template->param( adultborrower => 1 ) if ( $category_type eq 'A' || $category_type eq 'I' );
 }
 
 #title
index 59d4c0d..467997f 100644 (file)
@@ -15,7 +15,7 @@
     [% END %]
 
     [% IF CAN_user_borrowers_edit_borrowers %]
-        [% IF adultborrower AND Koha.Preference("borrowerRelationship") %]
+        [% IF patron.is_adult AND Koha.Preference("borrowerRelationship") %]
             <a id="addchild" class="btn btn-default btn-sm" href="/cgi-bin/koha/members/memberentry.pl?op=add&amp;guarantorid=[% patron.borrowernumber %]"><i class="fa fa-plus"></i> Add child</a>
         [% END %]
         [% IF CAN_user_borrowers_edit_borrowers %]
index d30dfe3..8643b90 100755 (executable)
@@ -96,8 +96,6 @@ foreach my $accountline ( @{$accts}) {
     }
 }
 
-$template->param( adultborrower => 1 ) if ( $patron->category->category_type =~ /^(A|I)$/ );
-
 if (C4::Context->preference('ExtendedPatronAttributes')) {
     my $attributes = GetBorrowerAttributes($borrowernumber);
     $template->param(
index ec5abe1..86ba249 100755 (executable)
@@ -109,8 +109,6 @@ my $dbh = C4::Context->dbh;
 my $is_guarantor = $dbh->selectrow_array("SELECT COUNT(*) FROM borrowers WHERE guarantorid=?", undef, $member);
 if ( $op eq 'delete_confirm' or $countissues > 0 or $flags->{'CHARGES'}  or $is_guarantor or $deletelocal == 0) {
 
-    $template->param( adultborrower => 1 ) if $patron->category->category_type =~ /^(A|I)$/;
-
     $template->param(
         patron => $patron,
     );
index 4fc42fc..7927eae 100755 (executable)
@@ -114,10 +114,6 @@ else {
         );
     }
 
-
-    $template->param( adultborrower => 1 )
-        if ( $patron_category->category_type eq 'A' || $patron_category->category_type eq 'I' );
-
     $template->param(
         files => Koha::Patron::Files->new( borrowernumber => $borrowernumber )
           ->GetFilesInfo(),
index 0e52085..9d65f4f 100755 (executable)
@@ -62,9 +62,8 @@ my $patron = Koha::Patrons->find($borrowernumber);
 output_and_exit_if_error( $input, $cookie, $template, { module => 'members', logged_in_user => $logged_in_user, current_patron => $patron } );
 
 # Get supporting cast
-my ( $branch, $category, $houseboundprofile, $visit );
+my ( $branch, $houseboundprofile, $visit );
 if ( $patron ) { # FIXME This test is not needed - output_and_exit_if_error handles it
-    $category = Koha::Patron::Categories->new->find($patron->categorycode);
     $houseboundprofile = $patron->housebound_profile;
 }
 if ( $visit_id ) {
@@ -167,7 +166,6 @@ if ( C4::Context->preference('ExtendedPatronAttributes') and $patron ) {
     );
 }
 
-$template->param( adultborrower => 1 ) if ( $category->category_type eq 'A' || $category->category_type eq 'I' );
 $template->param(
     housebound_profile => $houseboundprofile,
     visit              => $houseboundvisit,
index b1de0cc..9dfd2e6 100755 (executable)
@@ -85,8 +85,6 @@ if ($add){
         $template->param( 'catcode' => $patron_categories->next->categorycode )  if $patron_categories->count == 1;
     }
 
-    $template->param( adultborrower => 1 ) if ( $patron->category->category_type =~ /^(A|I)$/ );
-
     if (C4::Context->preference('ExtendedPatronAttributes')) {
         my $attributes = GetBorrowerAttributes($borrowernumber);
         $template->param(
index 6700188..68a4850 100755 (executable)
@@ -113,8 +113,6 @@ if ($add){
         $template->param( 'catcode' => $patron_categories->next->categorycode )  if $patron_categories->count == 1;
     }
 
-    $template->param( adultborrower => 1 ) if ( $patron->category->category_type =~ /^(A|I)$/ );
-
     if (C4::Context->preference('ExtendedPatronAttributes')) {
         my $attributes = GetBorrowerAttributes($borrowernumber);
         $template->param(
index 66debb6..63bb249 100755 (executable)
@@ -187,8 +187,6 @@ if ($input->param('newflags')) {
         $template->param( 'catcode' => $patron_categories->next->categorycode )  if $patron_categories->count == 1;
     }
 
-$template->param( adultborrower => 1 ) if ( $category_type =~ /^(A|I)$/ );
-
 if (C4::Context->preference('ExtendedPatronAttributes')) {
     my $attributes = GetBorrowerAttributes($bor->{'borrowernumber'});
     $template->param(
index 1a56dad..0e4db74 100755 (executable)
@@ -101,8 +101,6 @@ if ( $category_type eq 'C') {
     $template->param( 'catcode' => $patron_categories->next->categorycode )  if $patron_categories->count == 1;
 }
 
-$template->param( adultborrower => 1 ) if ( $category_type =~ /^(A|I)$/ );
-
 if ( C4::Context->preference('ExtendedPatronAttributes') ) {
     my $attributes = GetBorrowerAttributes( $bor->{'borrowernumber'} );
     $template->param(
index 8550dee..ebbdcac 100755 (executable)
@@ -196,8 +196,6 @@ my $relatives_issues_count =
   Koha::Database->new()->schema()->resultset('Issue')
   ->count( { borrowernumber => \@relatives } );
 
-$template->param( adultborrower => 1 ) if ( $category_type eq 'A' || $category_type eq 'I' );
-
 my %bor;
 $bor{'borrowernumber'} = $borrowernumber;
 
index 0541fd8..f307393 100755 (executable)
@@ -74,7 +74,6 @@ if (C4::Context->preference('ExtendedPatronAttributes')) {
     );
 }
 
-$template->param( adultborrower => 1 ) if ( $borrower->{category_type} eq 'A' || $borrower->{category_type} eq 'I' );
 $template->param(
     patron             => $patron,
     QUEUED_MESSAGES    => $queued_messages,
index da02121..d6080fb 100755 (executable)
@@ -114,8 +114,6 @@ for (my $i=0;$i<$numaccts;$i++){
     push(@accountrows, \%row);
 }
 
-$template->param( adultborrower => 1 ) if ( $category->category_type eq 'A' || $category->category_type eq 'I' );
-
 $template->param(
     patron               => $patron,
     finesview           => 1,
index 0a36d22..552e0cd 100755 (executable)
@@ -114,8 +114,6 @@ for ( my $i = 0 ; $i < $numaccts ; $i++ ) {
     push( @accountrows, \%row );
 }
 
-$template->param( adultborrower => 1 ) if ( $category->category_type eq 'A' || $category->category_type eq 'I' );
-
 $template->param(
     patron         => $patron,
     finesview      => 1,
index a8eaffe..7a63201 100755 (executable)
@@ -99,7 +99,6 @@ if ( $category->category_type eq 'C') {
     $template->param( 'catcode' => $patron_categories->next->categorycode )  if $patron_categories->count == 1;
 }
 
-$template->param( adultborrower => 1 ) if ( $category->category_type eq 'A' || $category->category_type eq 'I' );
 if (! $limit){
        $limit = 'full';
 }
index ff2de51..ca150ab 100755 (executable)
@@ -72,8 +72,6 @@ $template->param(
     routinglistview => 1
 );
 
-$template->param( adultborrower => 1 ) if ( $category->category_type =~ /^(A|I)$/ );
-
 $template->param(
     patron            => $patron,
     findborrower      => $findborrower,
index 98c157e..2e3087e 100755 (executable)
@@ -84,8 +84,6 @@ if (C4::Context->preference('ExtendedPatronAttributes')) {
     );
 }
 
-$template->param( adultborrower => 1 ) if ( $category->category_type eq 'A' || $category->category_type eq 'I' );
-
 $template->param(
     patron             => $patron,
     statisticsview     => 1,