From 09953f836de01a68a3117227965719b74f543844 Mon Sep 17 00:00:00 2001 From: Mathieu Saby Date: Thu, 19 Sep 2013 09:59:31 +0200 Subject: [PATCH] Bug 7791: add ability to delete records when deleting a basket Currently, when a basket is deleted, all the orders are deleted (there is a foreign key in aqorders table on basketno). This could be dangerous, and there is no warning. After the deletion, unused biblios are left in the catalogue. This patch - adds a more detailed message describing the consequences of deletion - give the choice of also deleting biblio records if possible To test : Test A : 1. create a basket with 4 orders: - an order from a new record A - an order from a record B which has already an item - an order from a record C used in a subscription - an order from a record D used in an other order 2. note the biblionumbers of the records used (or open them in other tabs in your browser) 3. click on "Delete basket" 4. choose button "Delete basket and orders" 5. check the catalogue : records A,B,C,D should still be there Test B: 1. create a basket with 4 orders: - an order from a new record A - an order from a record B which has already an item - an order from a record C used in a subscription - an order from a record D used in an other order 2. note the biblionumbers of the records used (or open them in other tabs in your browser) 3. click on "Delete basket" 4. choose button "Delete basket, orders and records" 5. check the catalogue : records B,C,D should still be there. Record A should be deleted Signed-off-by: Cedric Vita Signed-off-by: Chris Cormack Signed-off-by: Marcel de Rooy Signed-off-by: Galen Charlton --- acqui/basket.pl | 22 ++++++++++- .../prog/en/modules/acqui/basket.tt | 38 +++++++++++++------ 2 files changed, 47 insertions(+), 13 deletions(-) diff --git a/acqui/basket.pl b/acqui/basket.pl index e8b4199d59..df377887e4 100755 --- a/acqui/basket.pl +++ b/acqui/basket.pl @@ -110,7 +110,27 @@ $template->param( skip_confirm_reopen => 1) if $confirm_pref eq '2'; if ( $op eq 'delete_confirm' ) { my $basketno = $query->param('basketno'); - DelBasket($basketno); + my $delbiblio = $query->param('delbiblio'); + my @orders = GetOrders($basketno); +#Delete all orders included in that basket, and all items received. + foreach my $myorder (@orders){ + DelOrder($myorder->{biblionumber},$myorder->{ordernumber}); + warn "suppression de ".$myorder->{biblionumber}.' '.$myorder->{ordernumber}; + } +# if $delbiblio = 1, delete the records if possible + if ((defined $delbiblio)and ($delbiblio ==1)){ + foreach my $myorder (@orders){ + my $biblionumber = $myorder->{'biblionumber'}; + my $countbiblio = CountBiblioInOrders($biblionumber); + my $ordernumber = $myorder->{'ordernumber'}; + my @subscriptions = GetSubscriptionsId ($biblionumber); + my $itemcount = GetItemsCount($biblionumber); + DelBiblio($myorder->{biblionumber}) if ($countbiblio == 0 && $itemcount == 0 && !(@subscriptions)); + warn "suppression de la notice ".$myorder->{biblionumber}}; + } + + # delete the basket + DelBasket($basketno,); $template->param( delete_confirmed => 1 ); } elsif ( !$bookseller ) { $template->param( NO_BOOKSELLER => 1 ); diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/basket.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/basket.tt index 513664428f..057ab5103e 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/basket.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/basket.tt @@ -43,12 +43,11 @@ window.location = "[% script_name %]?op=close&basketno=[% basketno %]"; } } - function confirm_deletion() { - var is_confirmed = confirm(_("Are you sure you want to delete this basket?")); - if (is_confirmed) { - window.location = "[% script_name %]?op=delete_confirm&basketno=[% basketno %]&booksellerid=[% booksellerid %]"; - } + + function delete_basket(basketno,booksellerid,delbiblio) { + window.location = "[% script_name %]?op=delete_confirm&delbiblio="+delbiblio+"&basketno="+basketno+"&booksellerid="+booksellerid; } + function confirm_delete_item(ordernumber, biblionumber) { var is_confirmed = confirm(_("Are you sure you want to delete this order ?")); if (is_confirmed) { @@ -113,10 +112,6 @@ var cancelledorderst = $("#cancelledorderst").dataTable($.extend(true, {}, dataTablesDefaults, { "sPaginationType": "four_button" } ) ); - $("#delbasketbutton").on("click",function(e){ - e.preventDefault(); - confirm_deletion(); - }); $("#reopenbutton").on("click",function(e){ e.preventDefault(); confirm_reopen(); @@ -185,8 +180,8 @@
- - [% IF ( unclosable ) %] + + [% IF ( unclosable ) %] [% ELSIF ( uncertainprices ) %] [% ELSE %] @@ -195,8 +190,27 @@
[% END %] - + + + [% ELSE %] [% UNLESS ( grouped ) %]
-- 2.39.5