Bug 20805: Update child to adult patron process broken on several patron-related...
authorOwen Leonard <oleonard@myacpl.org>
Wed, 23 May 2018 12:43:55 +0000 (12:43 +0000)
committerNick Clemens <nick@bywatersolutions.com>
Fri, 13 Jul 2018 12:23:09 +0000 (12:23 +0000)
This patch fixes a problem with several patron-related pages, where the
"Update child to adult patron" menu item doesn't work. With some pages,
the right category information wasn't being passed from the script to
the template. With some, the right JavaScript variable weren't being
passed from the template to the included JavaScript file.

To test, apply the patch locate some patrons with "child" type patron
categories. With each patron, go to one of the following pages and test
the "update child" process in the toolbar's "More" menu.

 - Circulation ->
   - Batch check out
   - Notices
   - Statistics
   - Files
   - Housebound
   - Delete (test from the deletion confirmation screen).

All test should be performed on a system with multiple adult patron
categories configured AND on a system with only a single adult patron
category.

Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de>

Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>

Signed-off-by: Nick Clemens <nick@bywatersolutions.com>

koha-tmpl/intranet-tmpl/prog/en/modules/circ/circulation_batch_checkouts.tt
koha-tmpl/intranet-tmpl/prog/en/modules/members/deletemem.tt
koha-tmpl/intranet-tmpl/prog/en/modules/members/housebound.tt
koha-tmpl/intranet-tmpl/prog/en/modules/members/notices.tt
members/deletemem.pl
members/files.pl
members/housebound.pl
members/notices.pl
members/statistics.pl

index d45cb3d..44ad27b 100644 (file)
 [% MACRO jsinclude BLOCK %]
     [% INCLUDE 'calendar.inc' %]
     [% INCLUDE 'datatables.inc' %]
+    [% Asset.js("lib/jquery/plugins/jquery-ui-timepicker-addon.min.js") %]
     <script type="text/javascript">
+
+        /* Set some variables needed in members-menu.js */
+        var borrowernumber = "[% patron.borrowernumber %]";
+        var advsearch = "[% advsearch %]";
+        var dateformat = "[% dateformat %]";
+        var NorwegianPatronDBEnable = "[% NorwegianPatronDBEnable %]";
+        var CATCODE_MULTI = "[% CATCODE_MULTI %]";
+        var catcode = "[% catcode %]";
+        var destination = "[% destination %]";
+        var CAN_user_borrowers_edit_borrowers = "[% CAN_user_borrowers_edit_borrowers %]";
+
         $(document).ready(function() {
             if($('#barcodelist').length) {
                 $('#barcodelist').focus();
             }));
         });
     </script>
+    [% Asset.js("js/members-menu.js") %]
 [% END %]
 
 [% INCLUDE 'intranet-bottom.inc' %]
index 4d39a1b..a37cd5c 100644 (file)
 
 [% MACRO jsinclude BLOCK %]
     [% Asset.js("js/members-menu.js") %]
+    <script>
+        /* Set some variables needed in members-menu.js */
+        var borrowernumber = "[% patron.borrowernumber %]";
+        var advsearch = "[% advsearch %]";
+        var dateformat = "[% dateformat %]";
+        var NorwegianPatronDBEnable = "[% NorwegianPatronDBEnable %]";
+        var CATCODE_MULTI = "[% CATCODE_MULTI %]";
+        var catcode = "[% catcode %]";
+        var destination = "[% destination %]";
+        var CAN_user_borrowers_edit_borrowers = "[% CAN_user_borrowers_edit_borrowers %]";
+    </script>
 [% END %]
 
 [% INCLUDE 'intranet-bottom.inc' %]
index 696760d..e28d35c 100644 (file)
 
 [% MACRO jsinclude BLOCK %]
     [% INCLUDE 'calendar.inc' %]
-    [% Asset.js("js/members-menu.js") %]
     <script type="text/javascript">
+
+        /* Set some variables needed in members-menu.js */
+        var borrowernumber = "[% patron.borrowernumber %]";
+        var advsearch = "[% advsearch %]";
+        var dateformat = "[% dateformat %]";
+        var NorwegianPatronDBEnable = "[% NorwegianPatronDBEnable %]";
+        var CATCODE_MULTI = "[% CATCODE_MULTI %]";
+        var catcode = "[% catcode %]";
+        var destination = "[% destination %]";
+        var CAN_user_borrowers_edit_borrowers = "[% CAN_user_borrowers_edit_borrowers %]";
+
         $(document).ready(function() {
             $("a.delete").click(function(){
                 return confirm(_("Are you sure you want to delete this delivery?"));
             });
         });
     </script>
+    [% Asset.js("js/members-menu.js") %]
 [% END %]
 
 [% INCLUDE 'intranet-bottom.inc' %]
index 81e940f..7053532 100644 (file)
 </div>
 
 [% MACRO jsinclude BLOCK %]
-    [% Asset.js("js/members-menu.js") %]
     [% INCLUDE 'datatables.inc' %]
     <script type="text/javascript">
+
+        /* Set some variables needed in members-menu.js */
+        var borrowernumber = "[% patron.borrowernumber %]";
+        var advsearch = "[% advsearch %]";
+        var dateformat = "[% dateformat %]";
+        var NorwegianPatronDBEnable = "[% NorwegianPatronDBEnable %]";
+        var CATCODE_MULTI = "[% CATCODE_MULTI %]";
+        var catcode = "[% catcode %]";
+        var destination = "[% destination %]";
+        var CAN_user_borrowers_edit_borrowers = "[% CAN_user_borrowers_edit_borrowers %]";
+
         $(document).ready(function() {
             $("#noticestable").dataTable($.extend(true, {}, dataTablesDefaults, {
                 "aaSorting": [[ 3, "desc" ]],
             });
         });
     </script>
+    [% Asset.js("js/members-menu.js") %]
 [% END %]
 
 [% INCLUDE 'intranet-bottom.inc' %]
index 1da27fc..bc0c924 100755 (executable)
@@ -31,6 +31,7 @@ use C4::Members;
 use Module::Load;
 use Koha::Patrons;
 use Koha::Token;
+use Koha::Patron::Categories;
 
 if ( C4::Context->preference('NorwegianPatronDBEnable') && C4::Context->preference('NorwegianPatronDBEnable') == 1 ) {
     load Koha::NorwegianPatronDB, qw( NLMarkForDeletion NLSync );
@@ -100,6 +101,12 @@ if (C4::Context->preference("IndependentBranches")) {
     }
 }
 
+if ( $patron->is_child ) {
+    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->categorycode )  if $patron_categories->count == 1;
+}
+
 my $op = $input->param('op') || 'delete_confirm';
 my $dbh = C4::Context->dbh;
 my $is_guarantor = $dbh->selectrow_array("SELECT COUNT(*) FROM borrowers WHERE guarantorid=?", undef, $member);
index 7927eae..2e38c0d 100755 (executable)
@@ -30,6 +30,7 @@ use C4::Debug;
 use Koha::DateUtils;
 use Koha::Patrons;
 use Koha::Patron::Files;
+use Koha::Patron::Categories;
 
 my $cgi = CGI->new;
 
@@ -114,6 +115,12 @@ else {
         );
     }
 
+    if ( $patron->is_child ) {
+        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->categorycode )  if $patron_categories->count == 1;
+    }
+
     $template->param(
         files => Koha::Patron::Files->new( borrowernumber => $borrowernumber )
           ->GetFilesInfo(),
index 574bacd..69bdc1a 100755 (executable)
@@ -166,6 +166,12 @@ if ( C4::Context->preference('ExtendedPatronAttributes') and $patron ) {
     );
 }
 
+if ( $patron->is_child ) {
+    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->categorycode )  if $patron_categories->count == 1;
+}
+
 $template->param(
     housebound_profile => $houseboundprofile,
     visit              => $houseboundvisit,
index f307393..765b402 100755 (executable)
@@ -27,6 +27,7 @@ use C4::Members;
 use C4::Letters;
 use C4::Members::Attributes qw(GetBorrowerAttributes);
 use Koha::Patrons;
+use Koha::Patron::Categories;
 
 my $input=new CGI;
 
@@ -39,8 +40,7 @@ unless ( $patron ) {
 }
 my $borrower = $patron->unblessed;
 
-my ($template, $loggedinuser, $cookie)
-= get_template_and_user({template_name => "members/notices.tt",
+my ($template, $loggedinuser, $cookie)= get_template_and_user({template_name => "members/notices.tt",
                                query => $input,
                                type => "intranet",
                                authnotrequired => 0,
@@ -51,6 +51,12 @@ my ($template, $loggedinuser, $cookie)
 my $logged_in_user = Koha::Patrons->find( $loggedinuser ) or die "Not logged in";
 output_and_exit_if_error( $input, $cookie, $template, { module => 'members', logged_in_user => $logged_in_user, current_patron => $patron } );
 
+if ( $patron->is_child ) {
+    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->categorycode )  if $patron_categories->count == 1;
+}
+
 # Allow resending of messages in Notices tab
 my $op = $input->param('op') || q{};
 if ( $op eq 'resend_notice' ) {
index 2e3087e..0b02e03 100755 (executable)
@@ -32,6 +32,7 @@ use C4::Members::Statistics;
 use C4::Members::Attributes qw(GetBorrowerAttributes);
 use C4::Output;
 use Koha::Patrons;
+use Koha::Patron::Categories;
 
 my $input = new CGI;
 
@@ -84,6 +85,12 @@ if (C4::Context->preference('ExtendedPatronAttributes')) {
     );
 }
 
+if ( $patron->is_child ) {
+    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->categorycode )  if $patron_categories->count == 1;
+}
+
 $template->param(
     patron             => $patron,
     statisticsview     => 1,