From 2efa9af3472586c1346b99e8cd3bc7287a80c68f Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Tue, 17 Jul 2018 16:21:13 -0300 Subject: [PATCH] Bug 20226: Centralize update child code (CATCODE_MULTI) Code and variables to deal with the update child feature are not centralized but copied/pasted in several scripts. Which leads to issues obsviously (bug 20805 for instance). Moreover the strings used by the templates are also in several template files (or .inc) To deal with that this patch introduces the idea to create 1 .inc file per .js file Here we have members-menu.inc for members-menu.js Test plan: - Remove all your adult categories (categories.category_type='A') - Create a patron with a child category - Try to update to adult category => The entry does no longer appears! (This is a change in the behaviour) - Create one adult category - Update to adult category => There is a JS confirmation message, if you accept the patron will be updated to the adult category - Create (at least) another adult category - Create another child - Update to adult category => No more confirmation message but a popup to select the adult category - Pick one => The patron has been updated to the adult category Signed-off-by: Owen Leonard Signed-off-by: Josef Moravec --- Koha/Template/Plugin/Categories.pm | 3 ++- circ/circulation.pl | 6 ------ .../prog/en/includes/members-toolbar.inc | 11 ++++++---- .../prog/en/includes/patron-search.inc | 11 ---------- .../prog/en/includes/str/members-menu.inc | 24 +++++++++++++++++++++ .../prog/en/modules/circ/circulation.tt | 10 +-------- .../en/modules/circ/circulation_batch_checkouts.tt | 11 +--------- .../prog/en/modules/members/apikeys.tt | 1 + .../prog/en/modules/members/boraccount.tt | 2 +- .../prog/en/modules/members/deletemem.tt | 12 +---------- .../prog/en/modules/members/discharge.tt | 1 + .../prog/en/modules/members/discharges.tt | 1 + .../intranet-tmpl/prog/en/modules/members/files.tt | 1 + .../prog/en/modules/members/holdshistory.tt | 1 + .../prog/en/modules/members/housebound.tt | 11 +--------- .../prog/en/modules/members/mancredit.tt | 1 + .../prog/en/modules/members/maninvoice.tt | 1 + .../prog/en/modules/members/member-flags.tt | 1 + .../prog/en/modules/members/member-password.tt | 1 + .../prog/en/modules/members/member.tt | 1 + .../prog/en/modules/members/memberentrygen.tt | 1 + .../prog/en/modules/members/members-update.tt | 1 + .../prog/en/modules/members/merge-patrons.tt | 1 + .../prog/en/modules/members/moremember.tt | 1 + .../prog/en/modules/members/nl-search.tt | 1 + .../prog/en/modules/members/notices.tt | 11 +--------- .../intranet-tmpl/prog/en/modules/members/pay.tt | 1 + .../prog/en/modules/members/paycollect.tt | 1 + .../en/modules/members/purchase-suggestions.tt | 1 + .../prog/en/modules/members/readingrec.tt | 1 + .../prog/en/modules/members/routing-lists.tt | 1 + .../prog/en/modules/members/statistics.tt | 1 + .../prog/en/modules/members/update-child.tt | 25 +--------------------- .../prog/en/modules/tools/import_borrowers.tt | 1 + .../prog/en/modules/tools/picture-upload.tt | 1 + koha-tmpl/intranet-tmpl/prog/js/members-menu.js | 6 +++--- members/boraccount.pl | 6 ------ members/deletemem.pl | 6 ------ members/files.pl | 6 ------ members/holdshistory.pl | 6 ------ members/housebound.pl | 6 ------ members/mancredit.pl | 5 ----- members/maninvoice.pl | 6 ------ members/member-flags.pl | 6 ------ members/member-password.pl | 6 ------ members/moremember.pl | 6 ------ members/notices.pl | 6 ------ members/pay.pl | 6 ------ members/paycollect.pl | 5 ----- members/printinvoice.pl | 6 ------ members/readingrec.pl | 6 ------ members/statistics.pl | 6 ------ members/update-child.pl | 21 +++++++++++++----- 53 files changed, 82 insertions(+), 199 deletions(-) create mode 100644 koha-tmpl/intranet-tmpl/prog/en/includes/str/members-menu.inc diff --git a/Koha/Template/Plugin/Categories.pm b/Koha/Template/Plugin/Categories.pm index 2a7ae53..9716500 100644 --- a/Koha/Template/Plugin/Categories.pm +++ b/Koha/Template/Plugin/Categories.pm @@ -23,7 +23,8 @@ use base qw( Template::Plugin ); use Koha::Patron::Categories; sub all { - return Koha::Patron::Categories->search_limited; + my ( $self, $params ) = @_; + return Koha::Patron::Categories->search_limited($params); } sub GetName { diff --git a/circ/circulation.pl b/circ/circulation.pl index 1617584..5c858f7 100755 --- a/circ/circulation.pl +++ b/circ/circulation.pl @@ -537,12 +537,6 @@ if ( $patron ) { } } -if ( $patron && $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 $messages = Koha::Patron::Messages->search( { 'me.borrowernumber' => $borrowernumber, diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/members-toolbar.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/members-toolbar.inc index 1897af7..67f4ce0 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/includes/members-toolbar.inc +++ b/koha-tmpl/intranet-tmpl/prog/en/includes/members-toolbar.inc @@ -2,6 +2,7 @@ [% USE Koha %] [% USE Borrowers %] [% USE Branches %] +[% USE Categories %] [% USE AuthorisedValues %] [% SET NorwegianPatronDBEnable = Koha.Preference( 'NorwegianPatronDBEnable' ) %]
@@ -81,10 +82,12 @@ [% ELSE %]
  • Delete
  • [% END %] - [% IF ( patron.is_child ) %] -
  • Update child to adult patron
  • - [% ELSE %] -
  • Update child to adult patron
  • + [% IF Categories.scalar.all(category_type => 'A').count > 0 %] + [% IF patron.is_child %] +
  • Update child to adult patron
  • + [% ELSE %] +
  • Update child to adult patron
  • + [% END %] [% END %] [% IF Koha.Preference('intranetreadinghistory') %] [%IF ( privacy == 2 ) %] diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/patron-search.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/patron-search.inc index 84e67a3..71dfeee 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/includes/patron-search.inc +++ b/koha-tmpl/intranet-tmpl/prog/en/includes/patron-search.inc @@ -156,14 +156,3 @@
    - - diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/str/members-menu.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/str/members-menu.inc new file mode 100644 index 0000000..bd86309 --- /dev/null +++ b/koha-tmpl/intranet-tmpl/prog/en/includes/str/members-menu.inc @@ -0,0 +1,24 @@ +[% USE scalar %] +[% USE Koha %] +[% USE Categories %] + + diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/circulation.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/circ/circulation.tt index a6e6ba0..136602c 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/circulation.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/circ/circulation.tt @@ -1003,15 +1003,6 @@ No patron matched [% message | html %] var MSG_EXPORT_SELECT_CHECKOUTS = _("You must select checkout(s) to export"); var MSG_CONFIRM_DELETE_MESSAGE = _("Are you sure you want to delete this message? This cannot be undone."); - /* Set some variables needed in members-menu.js */ - 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 %]"; - columns_settings = [% ColumnsSettings.GetColumns( 'circ', 'circulation', 'issues-table', 'json' ) %] [% IF borrowernumber and patron %] @@ -1104,6 +1095,7 @@ No patron matched [% message | html %] [% END %] }); + [% INCLUDE 'str/members-menu.inc' %] [% Asset.js("js/members-menu.js") %] [% END %] diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/circulation_batch_checkouts.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/circ/circulation_batch_checkouts.tt index 44ad27b..7bfcd00 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/circulation_batch_checkouts.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/circ/circulation_batch_checkouts.tt @@ -295,16 +295,6 @@ [% Asset.js("lib/jquery/plugins/jquery-ui-timepicker-addon.min.js") %] + [% INCLUDE 'str/members-menu.inc' %] [% Asset.js("js/members-menu.js") %] [% END %] diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/members/apikeys.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/members/apikeys.tt index 418c7d1..e615ba0 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/members/apikeys.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/members/apikeys.tt @@ -100,6 +100,7 @@ [% MACRO jsinclude BLOCK %] + [% INCLUDE 'str/members-menu.inc' %] [% Asset.js("js/members-menu.js") %] [% END %] [% INCLUDE 'intranet-bottom.inc' %] diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/members/discharge.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/members/discharge.tt index f4a725b..f2a51ba 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/members/discharge.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/members/discharge.tt @@ -74,6 +74,7 @@ [% MACRO jsinclude BLOCK %] + [% INCLUDE 'str/members-menu.inc' %] [% Asset.js("js/members-menu.js") %] [% END %] diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/members/discharges.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/members/discharges.tt index f4456ae..5c27c04 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/members/discharges.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/members/discharges.tt @@ -51,6 +51,7 @@ [% MACRO jsinclude BLOCK %] + [% INCLUDE 'str/members-menu.inc' %] [% Asset.js("js/members-menu.js") %] [% INCLUDE 'datatables.inc' %] diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/members/files.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/members/files.tt index a046fb3..0cdffa4 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/members/files.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/members/files.tt @@ -86,6 +86,7 @@ [% MACRO jsinclude BLOCK %] + [% INCLUDE 'str/members-menu.inc' %] [% Asset.js("js/members-menu.js") %] + [% INCLUDE 'str/members-menu.inc' %] [% Asset.js("js/members-menu.js") %] [% END %] diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/members/mancredit.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/members/mancredit.tt index 9aca8b5..68e36a1 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/members/mancredit.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/members/mancredit.tt @@ -60,6 +60,7 @@ [% MACRO jsinclude BLOCK %] + [% INCLUDE 'str/members-menu.inc' %] [% Asset.js("js/members-menu.js") %] + [% INCLUDE 'str/members-menu.inc' %] [% Asset.js("js/members-menu.js") %] [% END %] diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/members/pay.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/members/pay.tt index c234c23..ec72e85 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/members/pay.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/members/pay.tt @@ -138,6 +138,7 @@ [% MACRO jsinclude BLOCK %] + [% INCLUDE 'str/members-menu.inc' %] [% Asset.js("js/members-menu.js") %] [% Asset.js("lib/jquery/plugins/jquery.checkboxes.min.js") %] - [% IF ( CONFIRM ) %] - - [% END %] [% IF ( SUCCESS ) %] [% END %] + [% INCLUDE 'str/members-menu.inc' %] [% Asset.js("js/members-menu.js") %] [% END %] diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/import_borrowers.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/tools/import_borrowers.tt index f2b5c3c..119b01b 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/import_borrowers.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/tools/import_borrowers.tt @@ -291,6 +291,7 @@ you can supply dates in ISO format (e.g., '2010-10-28'). [% MACRO jsinclude BLOCK %] [% INCLUDE 'calendar.inc' %] [% Asset.js("js/tools-menu.js") %] + [% INCLUDE 'str/members-menu.inc' %] [% Asset.js("js/members-menu.js") %]