diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/stockrotation.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/tools/stockrotation.tt index 1db4229438..a7f58583ab 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/stockrotation.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/tools/stockrotation.tt @@ -146,6 +146,10 @@ Deactivate [% END %] + + + Delete + [% END %] @@ -368,6 +372,22 @@ No

+ [% ELSIF (op == 'confirm_delete_rota') %] + +
+

Are you sure you want to delete this rota?

+ [% IF sritemstotal > 0 %] + [% IF sritemstotal == 1 %] +

[% sritemstotal | html %] item is still attached to this rota, that item will remain at its current stage libraries.

+ [% ELSE %] +

[% sritemstotal | html %] items are still attached to this rota, those items will remain at their current stage libraries.

+ [% END %] + [% END %] +

+ Yes + No +

+
[% ELSIF (op == 'confirm_delete_stage') %]
diff --git a/tools/stockrotation.pl b/tools/stockrotation.pl index deaad70dcd..ec60a17864 100755 --- a/tools/stockrotation.pl +++ b/tools/stockrotation.pl @@ -193,6 +193,42 @@ if (!defined $op) { item_id => $params{item_id} ); +} elsif ($op eq 'confirm_delete_rota') { + + # Get the rota we're deleting + my $rota = Koha::StockRotationRotas->find($params{rota_id}); + + # Get all items on this rota, for each prefetch their + # stage and biblio objects + my $sritems = Koha::StockRotationItems->search( + { 'stage.rota_id' => $params{rota_id} }, + { + prefetch => { + stage => { + 'stockrotationitems' => { + 'itemnumber' => 'biblionumber' + } + } + } + } + ); + + $template->param( + rota_id => $params{rota_id}, + sritemstotal => $sritems->count, + op => $op + ); + +} elsif ($op eq 'delete_rota') { + + # Get the rota we're deleting + my $rota = Koha::StockRotationRotas->find($params{rota_id}); + + $rota->delete; + + # Return to the rotas list + print $input->redirect("/cgi-bin/koha/tools/stockrotation.pl"); + } elsif ($op eq 'confirm_delete_stage') { # Get the stage we're deleting