From bafd627d7a2c5fcdf9657cb9d0b8b0f26656bbee Mon Sep 17 00:00:00 2001 From: Kyle M Hall Date: Wed, 30 Jan 2013 11:36:38 -0500 Subject: [PATCH] Bug 5790 - Prevent deletion of records with holds Test Plan: 1) Apply patch 2) Create a record 3) Create an item for the record 3) Place a hold on the bib 4) Attempt to 'Delete all items', you should recieve an error message stating to delete all holds before deleting all items. Also, it is possible to get into a situation where a record has holds but no items. In this situation, it is not possible to view/delete the holds without adding an item back to the record. In this case, attempting to delete the bib causes a warning, but does not prevent deletion. Signed-off-by: Liz Rea Passes tests - do note that it was a design decision to leave the delete links clickable even though they are grey. The reasoning is that librarians will want to be able to know *why* they cannot delete a given item or bib - I like this. Signed-off-by: Jonathan Druart --- catalogue/ISBDdetail.pl | 4 + catalogue/MARCdetail.pl | 3 + catalogue/detail.pl | 7 +- catalogue/imageviewer.pl | 3 + catalogue/labeledMARCdetail.pl | 3 + catalogue/moredetail.pl | 4 + .../intranet-tmpl/prog/en/css/staff-global.css | 3 + .../intranet-tmpl/prog/en/includes/cat-toolbar.inc | 61 +++++++++++-------- 8 files changed, 58 insertions(+), 30 deletions(-) diff --git a/catalogue/ISBDdetail.pl b/catalogue/ISBDdetail.pl index de24490..f094160 100755 --- a/catalogue/ISBDdetail.pl +++ b/catalogue/ISBDdetail.pl @@ -111,5 +111,9 @@ $template->param ( C4::Search::enabled_staff_search_views, ); + +my ( $holdcount, $holds ) = C4::Reserves::GetReservesFromBiblionumber($biblionumber,1); +$template->param( holdcount => $holdcount, holds => $holds ); + output_html_with_http_headers $query, $cookie, $template->output; diff --git a/catalogue/MARCdetail.pl b/catalogue/MARCdetail.pl index 2b967df..d8079bd 100755 --- a/catalogue/MARCdetail.pl +++ b/catalogue/MARCdetail.pl @@ -335,4 +335,7 @@ $template->param ( C4::Search::enabled_staff_search_views, ); +my ( $holdcount, $holds ) = C4::Reserves::GetReservesFromBiblionumber($biblionumber,1); +$template->param( holdcount => $holdcount, holds => $holds ); + output_html_with_http_headers $query, $cookie, $template->output; diff --git a/catalogue/detail.pl b/catalogue/detail.pl index 88f64d1..6372fa6 100755 --- a/catalogue/detail.pl +++ b/catalogue/detail.pl @@ -137,9 +137,6 @@ if (@hostitems){ my $dat = &GetBiblioData($biblionumber); -# get count of holds -my ( $holdcount, $holds ) = GetReservesFromBiblionumber($biblionumber,1); - #coping with subscriptions my $subscriptionsnumber = CountSubscriptionFromBiblionumber($biblionumber); my @subscriptions = GetSubscriptions( $dat->{title}, $dat->{issn}, undef, $biblionumber ); @@ -282,7 +279,6 @@ $template->param( volinfo => $itemfields{enumchron}, itemdata_itemnotes => $itemfields{itemnotes}, z3950_search_params => C4::Search::z3950_search_args($dat), - holdcount => $holdcount, hostrecords => $hostrecords, analytics_flag => $analytics_flag, C4::Search::enabled_staff_search_views, @@ -373,4 +369,7 @@ if (C4::Context->preference('TagsEnabled') and $tag_quantity = C4::Context->pref 'sort'=>'-weight', limit=>$tag_quantity})); } +my ( $holdcount, $holds ) = C4::Reserves::GetReservesFromBiblionumber($biblionumber,1); +$template->param( holdcount => $holdcount, holds => $holds ); + output_html_with_http_headers $query, $cookie, $template->output; diff --git a/catalogue/imageviewer.pl b/catalogue/imageviewer.pl index a5f86a5..c96e5af 100755 --- a/catalogue/imageviewer.pl +++ b/catalogue/imageviewer.pl @@ -78,4 +78,7 @@ $template->{VARS}->{'norequests'} = $norequests; $template->param(C4::Search::enabled_staff_search_views); $template->{VARS}->{'biblio'} = $biblio; +my ( $holdcount, $holds ) = C4::Reserves::GetReservesFromBiblionumber($biblionumber,1); +$template->param( holdcount => $holdcount, holds => $holds ); + output_html_with_http_headers $query, $cookie, $template->output; diff --git a/catalogue/labeledMARCdetail.pl b/catalogue/labeledMARCdetail.pl index b8c7982..9d2a14e 100755 --- a/catalogue/labeledMARCdetail.pl +++ b/catalogue/labeledMARCdetail.pl @@ -136,4 +136,7 @@ $template->param ( C4::Search::enabled_staff_search_views, ); +my ( $holdcount, $holds ) = C4::Reserves::GetReservesFromBiblionumber($biblionumber,1); +$template->param( holdcount => $holdcount, holds => $holds ); + output_html_with_http_headers $query, $cookie, $template->output; diff --git a/catalogue/moredetail.pl b/catalogue/moredetail.pl index 66d731b..6e99c60 100755 --- a/catalogue/moredetail.pl +++ b/catalogue/moredetail.pl @@ -214,5 +214,9 @@ $template->param( ); $template->param(ONLY_ONE => 1) if ( $itemnumber && $showncount != @items ); + +my ( $holdcount, $holds ) = GetReservesFromBiblionumber($biblionumber,1); +$template->param( holdcount => $holdcount, holds => $holds ); + output_html_with_http_headers $query, $cookie, $template->output; diff --git a/koha-tmpl/intranet-tmpl/prog/en/css/staff-global.css b/koha-tmpl/intranet-tmpl/prog/en/css/staff-global.css index 782a76d..8287632 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/css/staff-global.css +++ b/koha-tmpl/intranet-tmpl/prog/en/css/staff-global.css @@ -475,6 +475,9 @@ ul.toolbar button { a.yuimenuitemlabel-disabled, #disabled a { color: #999; } +a.yuimenuitemlabel-disabled, #disabled2 a { + color: #999; +} a.yuimenuitemlabel-disabled:hover, #disabled a:hover { color : #999; } 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 740a3b5..3e7337e 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/includes/cat-toolbar.inc +++ b/koha-tmpl/intranet-tmpl/prog/en/includes/cat-toolbar.inc @@ -26,40 +26,49 @@ function printBiblio() {window.open('/cgi-bin/koha/catalogue/detailprint.pl?biblionumber=[% biblionumber %]','Print_Biblio','width=700,height=500,toolbar=false,scrollbars=yes'); } [% IF ( CAN_user_editcatalogue_edit_catalogue ) %] -function confirm_deletion() { - var count = [% count %]; - var is_confirmed; - if (count>0){ - is_confirmed= alert(_('There are [ '+ count +' ] item(s) attached to this record \n You must delete all items before deleting this record.')); - } else{ - is_confirmed= confirm(_('Are you sure you want to delete this record? ')); - } + function confirm_deletion() { + var count = [% count %]; + var holdcount = [% holdcount %]; - if (is_confirmed) { - if (count>0){ - // window.location="/cgi-bin/koha/catalogue/detail.pl?biblionumber=[% biblionumber %]"; - } else { - window.location="/cgi-bin/koha/cataloguing/addbiblio.pl?op=delete&biblionumber=[% biblionumber %]"; - } + var is_confirmed; + if (count > 0){ + is_confirmed = alert( count + " " +_("item(s) are attached to this record.\nYou must delete all items before deleting this record.") ); + } else if ( holdcount > 0 ) { + is_confirmed = confirm( holdcount + " " + _("holds(s) for this record \n Are you sure you want to delete this record?.")); + } else { + is_confirmed = confirm(_('Are you sure you want to delete this record? ')); + } + + if (is_confirmed) { + if ( count > 0 || holdcount > 0 ){ + return false; + } else { + window.location="/cgi-bin/koha/cataloguing/addbiblio.pl?op=delete&biblionumber=[% biblionumber %]"; + } } else { - return false; + return false; } -} + } [% END %] + [% IF ( CAN_user_editcatalogue_edit_items ) %] -function confirm_items_deletion() { + function confirm_items_deletion() { var count = [% count %]; - if(count > 0){ - if(confirm(_('Are you sure you want to delete the ' + count + ' attached items? '))){ + var holdcount = [% holdcount %]; + + if ( holdcount > 0 ) { + alert( holdcount + " " + _("holds(s) for this record \n You must delete all holds before deleting all items.") ); + } else if ( count > 0 ) { + if( confirm( _("Are you sure you want to delete the") + " " + count + " " + _("attached items?") ) ) { window.location="/cgi-bin/koha/cataloguing/additem.pl?op=delallitems&biblionumber=[% biblionumber %]"; - }else{ + } else { return false; } - } else { - alert(_("This record has no items.")); - return false; - } -} + } else { + alert(_("This record has no items.")); + return false; + } + } [% END %] // prepare DOM for YUI Toolbar @@ -117,8 +126,8 @@ function confirm_items_deletion() { [% IF ( LocalCoverImages || OPACLocalCoverImages) %][% IF ( CAN_user_tools_upload_local_cover_images ) %]{ text: _("Upload image"), url: "/cgi-bin/koha/tools/upload-cover-image.pl?biblionumber=[% biblionumber %]&filetype=image" },[% END %][% END %] [% IF ( CAN_user_editcatalogue_edit_catalogue ) %]{ text: _("Edit as new (duplicate)"), url: "/cgi-bin/koha/cataloguing/addbiblio.pl?biblionumber=[% biblionumber %]&frameworkcode=&op=duplicate" },[% END %] [% IF ( CAN_user_editcatalogue_edit_catalogue ) %]{ text: _("Replace record via Z39.50"), onclick: {fn: PopupZ3950 } },[% END %] - [% IF ( CAN_user_editcatalogue_edit_catalogue ) %]{ text: _("Delete record"), onclick: {fn: confirm_deletion }[% IF ( count ) %],id:'disabled'[% END %] },[% END %] - [% IF ( CAN_user_editcatalogue_edit_items ) %]{ text: _("Delete all items"), onclick: {fn: confirm_items_deletion }[% UNLESS ( count ) %],id:'disabled'[% END %] }[% END %] + [% IF ( CAN_user_editcatalogue_edit_catalogue ) %]{ text: _("Delete record"), onclick: {fn: confirm_deletion }[% IF ( count || holdcount ) %],id:'disabled'[% END %] },[% END %] + [% IF ( CAN_user_editcatalogue_edit_items ) %]{ text: _("Delete all items"), onclick: {fn: confirm_items_deletion }[% IF ( count < 1 || holdcount ) %],id:'disabled2'[% END %] },[% END %] ]; if(editmenu.length){ new YAHOO.widget.Button({ -- 1.7.2.5