From b808169915a839d04ff4f6fc3f71de401778df36 Mon Sep 17 00:00:00 2001 From: Julian Maurice Date: Fri, 9 Nov 2012 15:16:52 +0100 Subject: [PATCH 1/2] Bug 9044: Provide item selection in record detail page (staff client) This patch add a column in the items table of catalogue/detail.pl that contains checkboxes for item selection and a drop-down list of actions that can be executed for the selection of items. Currently available actions are: - Delete selected items: redirect to batch items deletion - Modify selected items: redirect to batch items modification These actions replace the two menu entries corresponding to the same action. Item selection is only enabled if the new syspref StaffDetailItemSelection is ON. Actions are not displayed if user doesn't have the right permissions. Signed-off-by: Kyle M Hall --- catalogue/detail.pl | 20 ++++++- installer/data/mysql/sysprefs.sql | 1 + installer/data/mysql/updatedatabase.pl | 10 ++++ .../intranet-tmpl/prog/en/includes/cat-toolbar.inc | 4 -- .../en/modules/admin/preferences/staff_client.pref | 6 ++ .../prog/en/modules/catalogue/detail.tt | 60 ++++++++++++++++++++ .../prog/en/modules/tools/batchMod-del.tt | 4 +- .../prog/en/modules/tools/batchMod-edit.tt | 4 +- 8 files changed, 100 insertions(+), 9 deletions(-) diff --git a/catalogue/detail.pl b/catalogue/detail.pl index a5b32c6..dbe4a9c 100755 --- a/catalogue/detail.pl +++ b/catalogue/detail.pl @@ -48,7 +48,7 @@ my $query = CGI->new(); my $analyze = $query->param('analyze'); -my ( $template, $borrowernumber, $cookie ) = get_template_and_user( +my ( $template, $borrowernumber, $cookie, $flags ) = get_template_and_user( { template_name => 'catalogue/detail.tmpl', query => $query, @@ -405,5 +405,23 @@ if (C4::Context->preference('TagsEnabled') and $tag_quantity = C4::Context->pref my ( $holdcount, $holds ) = C4::Reserves::GetReservesFromBiblionumber($biblionumber,1); $template->param( holdcount => $holdcount, holds => $holds ); +my $StaffDetailItemSelection = C4::Context->preference('StaffDetailItemSelection'); +if ($StaffDetailItemSelection) { + # Only enable item selection if user can execute at least one action + if ( + $flags->{superlibrarian} + || ( + ref $flags->{tools} eq 'HASH' && ( + $flags->{tools}->{items_batchmod} # Modify selected items + || $flags->{tools}->{items_batchdel} # Delete selected items + ) + ) + || ( ref $flags->{tools} eq '' && $flags->{tools} ) + ) + { + $template->param( + StaffDetailItemSelection => $StaffDetailItemSelection ); + } +} output_html_with_http_headers $query, $cookie, $template->output; diff --git a/installer/data/mysql/sysprefs.sql b/installer/data/mysql/sysprefs.sql index df821c0..5143a51 100644 --- a/installer/data/mysql/sysprefs.sql +++ b/installer/data/mysql/sysprefs.sql @@ -419,3 +419,4 @@ INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES(' INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES('FinesIncludeGracePeriod','1','If enabled, fines calculations will include the grace period.',NULL,'YesNo'); INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES ('UNIMARCAuthorsFacetsSeparator',', ', 'UNIMARC authors facets separator', NULL, 'short'); INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES('UseKohaPlugins','1','Enable or disable the ability to use Koha Plugins.','','YesNo'); +INSERT INTO systempreferences (variable, value, explanation, options, type) VALUES ('StaffDetailItemSelection', '0', 'Enable item selection in record detail page', NULL, 'YesNo'); diff --git a/installer/data/mysql/updatedatabase.pl b/installer/data/mysql/updatedatabase.pl index 222428d..0f305d9 100755 --- a/installer/data/mysql/updatedatabase.pl +++ b/installer/data/mysql/updatedatabase.pl @@ -6655,6 +6655,16 @@ if ( C4::Context->preference("Version") < TransformToNum($DBversion) ) { SetVersion($DBversion); } +$DBversion = "3.11.00.XXX"; +if (C4::Context->preference('Version') < TransformToNum($DBversion)) { + $dbh->do(qq{ + INSERT INTO systempreferences (variable, value, explanation, options, type) + VALUES ('StaffDetailItemSelection', '0', 'Enable item selection in record detail page', NULL, 'YesNo') + }); + print "Upgrade to $DBversion done (Add system preference StaffDetailItemSelection)\n"; + SetVersion($DBversion); +} + =head1 FUNCTIONS =head2 TableExists($table) diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/cat-toolbar.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/cat-toolbar.inc index 2dde5ad..f43b55a 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/includes/cat-toolbar.inc +++ b/koha-tmpl/intranet-tmpl/prog/en/includes/cat-toolbar.inc @@ -145,10 +145,6 @@ CAN_user_serials_create_subscription ) %]
  • Edit items
  • [% END %] - [% IF ( CAN_user_tools_items_batchmod ) %]
  • Edit items in batch
  • [% END %] - - [% IF ( CAN_user_tools_items_batchdel ) %]
  • Delete items in a batch
  • [% END %] - [% IF ( CAN_user_editcatalogue_edit_items ) %]
  • Attach item
  • [% END %] [% IF ( EasyAnalyticalRecords ) %][% IF ( CAN_user_editcatalogue_edit_items ) %]
  • Link to host item[% END %][% END %] diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/staff_client.pref b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/staff_client.pref index d9fc21a..65746f0 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/staff_client.pref +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/staff_client.pref @@ -122,3 +122,9 @@ Staff Client: yes: Show no: "Don't show" - the cart option in the staff client. + - + - pref: StaffDetailItemSelection + choices: + yes: Enable + no: Disable + - item selection in record detail page. diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/detail.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/detail.tt index 8f40e31..73c0c74 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/detail.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/detail.tt @@ -36,6 +36,42 @@ function verify_images() { } }); } + + [% IF StaffDetailItemSelection %] + function selectAllItems(div) { + $("input[name='itemnumber'][type='checkbox']", div).attr('checked', 'checked'); + } + + function deselectAllItems(div) { + $("input[name='itemnumber'][type='checkbox']", div).removeAttr('checked'); + } + + function itemSelectionExecuteAction(div) { + var itemnumbers = new Array(); + $("input[name='itemnumber'][type='checkbox']:checked", div).each(function() { + itemnumbers.push($(this).val()); + }); + if (itemnumbers.length > 0) { + var action = $('select[name="itemselection_action"]', div).val(); + var del = (action == 'delete') ? 1 : 0; + var url = '/cgi-bin/koha/tools/batchMod.pl?op=show'; + if (action == 'delete') { + url += '&del=1'; + } + url += '&itemnumber=' + itemnumbers.join('&itemnumber='); + url += '&src=' + '[% "/cgi-bin/koha/catalogue/detail.pl?biblionumber=$biblionumber" |uri %]'; + new_window = $("input[name='new_window']", div).attr('checked'); + if (new_window) { + window.open(url); + } else { + window.location.href = url; + } + } else { + alert(_("Please select at least one item.")); + } + } + [% END %] + $(document).ready(function() { $('#bibliodetails').tabs(); $('#search-form').focus(); @@ -351,9 +387,28 @@ function verify_images() { [% BLOCK items_table %] + [% IF (StaffDetailItemSelection) %] + Select all | + Deselect all | +
    + + + + + +
    + [% END %] + [% IF (StaffDetailItemSelection) %][% END %] [% IF ( item_level_itypes ) %][% END %] @@ -375,6 +430,11 @@ function verify_images() { [% FOREACH item IN items %] + [% IF (StaffDetailItemSelection) %] + + [% END %] [% IF ( item_level_itypes ) %]
    Item typeCurrent location Home Library
    + + [% IF !noItemTypeImages && item.imageurl %] diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/batchMod-del.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/tools/batchMod-del.tt index e3f6b29..89db154 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/batchMod-del.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/tools/batchMod-del.tt @@ -178,8 +178,8 @@ for( x=0; x - [% IF ( src == 'CATALOGUING') %] - Done + [% IF src %] + Done [% ELSE %] Return to batch item deletion [% END %] diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/batchMod-edit.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/tools/batchMod-edit.tt index c65277a..141092d 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/batchMod-edit.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/tools/batchMod-edit.tt @@ -190,8 +190,8 @@ $(document).ready(function(){ [% END %] [% ELSE %]
    -[% IF ( src == 'CATALOGUING') %] - Done +[% IF src %] + Done [% ELSE %] Done [% END %] -- 1.7.10.4