diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/labels/label-edit-batch.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/labels/label-edit-batch.tt index 40630b6dca..760e2ff5f1 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/labels/label-edit-batch.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/labels/label-edit-batch.tt @@ -166,8 +166,9 @@ [% FOREACH text_field IN table_loo.text_fields %] [% IF ( text_field.select_field ) %] - - Delete + + Delete + Export @@ -208,6 +209,11 @@ +
+ [% INCLUDE 'csrf-token.inc' %] + + +
[% MACRO jsinclude BLOCK %] [% INCLUDE 'greybox.inc' %] [% INCLUDE 'datatables.inc' %] @@ -225,17 +231,18 @@ return true; // ok } } + function Remove() { + const batch_remove_form = $("#batch_remove_form"); items = new Array; item_num = new Array; if(document.items.action.length > 0) { for (var i=0; i < document.items.action.length; i++) { if (document.items.action[i].checked) { - items.push("label_id=" + document.items.action[i].value); - item_num.push(i+1); + items.push( document.items.action[i].value ); + item_num.push( i + 1 ); } } - getstr = items.join("&"); item_msg = item_num.join(", "); var msg = _("Are you sure you want to remove label number(s): %s from this batch?").format(item_msg); } else if (document.items.action.checked) { @@ -245,13 +252,16 @@ alert(_("Please select at least one label to delete.")); return; // no item selected } - var answer = confirm(msg); - if (answer) { - window.location = "/cgi-bin/koha/labels/label-edit-batch.pl?op=remove&batch_id=[% batch_id | html %]&" + getstr; + if ( confirm( msg ) ) { + items.forEach(( label_id ) => { + batch_remove_form.append(''); + }); + batch_remove_form.submit(); } else { return; // abort delete } } + function Add() { var number_list = document.getElementById("number_list"); if (number_list.value == '') { diff --git a/labels/label-edit-batch.pl b/labels/label-edit-batch.pl index 23bd9e77d4..1a8759b49b 100755 --- a/labels/label-edit-batch.pl +++ b/labels/label-edit-batch.pl @@ -67,7 +67,7 @@ $number_list = $cgi->param('number_list') if $cgi->param('number_list'); my $branch_code = C4::Context->userenv->{'branch'}; -if ($op eq 'remove') { +if ($op eq 'cud-delete') { $batch = C4::Labels::Batch->retrieve(batch_id => $batch_id); foreach my $label_id (@label_ids) { $err = $batch->remove_item($label_id); @@ -77,10 +77,6 @@ if ($op eq 'remove') { # print $cgi->redirect("label-edit-batch.pl?op=edit&batch_id=$batch_id"); # exit; } -elsif ($op eq 'cud-delete') { - $err = C4::Labels::Batch::delete(batch_id => $batch_id, branch_code => $branch_code); - $errtype = 'BATCH_NOT_DELETED' if $err; -} elsif ($op eq 'cud-add') { if ($number_list) { my @numbers_list = split /\n/, $number_list; # Entries are effectively passed in as a separated list