View | Details | Raw Unified | Return to bug 37206
Collapse All | Expand All

(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/labels/label-edit-batch.tt (-8 / +18 lines)
Lines 166-173 Link Here
166
                                                        <tr>
166
                                                        <tr>
167
                                                            [% FOREACH text_field IN table_loo.text_fields %]
167
                                                            [% FOREACH text_field IN table_loo.text_fields %]
168
                                                                [% IF ( text_field.select_field ) %]
168
                                                                [% IF ( text_field.select_field ) %]
169
                                                                    <td>
169
                                                                    <td class="actions">
170
                                                                        <a class="btn btn-default btn-xs delete" href="/cgi-bin/koha/labels/label-edit-batch.pl?op=remove&amp;batch_id=[% batch_id |url %]&amp;label_id=[% text_field.field_value |url %]"><i class="fa fa-trash-can"></i> Delete</a>
170
                                                                        <a class="btn btn-default btn-xs submit-form-link" id="deletebatch" href="#" data-op="cud-delete" data-batch_id="[% batch_id | html %]" data-label_id="[% text_field.field_value | html %]" data-method="post" data-action="/cgi-bin/koha/labels/label-edit-batch.pl" data-confirmation-msg="Are you sure you want to delete this?"><i class="fa fa-trash-can"></i> Delete</a>
171
171
                                                                        <a class="btn btn-default btn-xs export" href="#" data-batch-id="[% batch_id | html %]" data-label-id="[% text_field.field_value | html %]"><i class="fa-solid fa-share-from-square"></i> Export</a>
172
                                                                        <a class="btn btn-default btn-xs export" href="#" data-batch-id="[% batch_id | html %]" data-label-id="[% text_field.field_value | html %]"><i class="fa-solid fa-share-from-square"></i> Export</a>
172
                                                                    </td>
173
                                                                    </td>
173
                                                                    <td><input type="checkbox" name="action" value="[% text_field.field_value | html %]"></td>
174
                                                                    <td><input type="checkbox" name="action" value="[% text_field.field_value | html %]"></td>
Lines 205-210 Link Here
205
        </div> <!-- /.col-sm-2.col-sm-pull-10 -->
206
        </div> <!-- /.col-sm-2.col-sm-pull-10 -->
206
     </div> <!-- /.row -->
207
     </div> <!-- /.row -->
207
208
209
    <form action="/cgi-bin/koha/labels/label-edit-batch.pl" id="batch_remove_form" method="post">
210
        [% INCLUDE 'csrf-token.inc' %]
211
        <input type="hidden" name="op" value="cud-delete" />
212
        <input type="hidden" name="batch_id" value="[% batch_id | html %]" />
213
    </form>
208
[% MACRO jsinclude BLOCK %]
214
[% MACRO jsinclude BLOCK %]
209
    [% INCLUDE 'greybox.inc' %]
215
    [% INCLUDE 'greybox.inc' %]
210
    [% INCLUDE 'datatables.inc' %]
216
    [% INCLUDE 'datatables.inc' %]
Lines 222-238 Link Here
222
                return true;    // ok
228
                return true;    // ok
223
            }
229
            }
224
        }
230
        }
231
225
        function Remove() {
232
        function Remove() {
233
            const batch_remove_form = $("#batch_remove_form");
226
            items = new Array;
234
            items = new Array;
227
            item_num = new Array;
235
            item_num = new Array;
228
            if(document.items.action.length > 0) {
236
            if(document.items.action.length > 0) {
229
                for (var i=0; i < document.items.action.length; i++) {
237
                for (var i=0; i < document.items.action.length; i++) {
230
                    if (document.items.action[i].checked) {
238
                    if (document.items.action[i].checked) {
231
                        items.push("label_id=" +  document.items.action[i].value);
239
                        items.push( document.items.action[i].value );
232
                        item_num.push(i+1);
240
                        item_num.push( i + 1 );
233
                    }
241
                    }
234
                }
242
                }
235
                getstr = items.join("&");
236
                item_msg = item_num.join(", ");
243
                item_msg = item_num.join(", ");
237
                var msg = _("Are you sure you want to remove label number(s): %s from this batch?").format(item_msg);
244
                var msg = _("Are you sure you want to remove label number(s): %s from this batch?").format(item_msg);
238
            } else if (document.items.action.checked) {
245
            } else if (document.items.action.checked) {
Lines 242-254 Link Here
242
                alert(_("Please select at least one label to delete."));
249
                alert(_("Please select at least one label to delete."));
243
                return;     // no item selected
250
                return;     // no item selected
244
            }
251
            }
245
            var answer = confirm(msg);
252
            if ( confirm( msg ) ) {
246
            if (answer) {
253
                items.forEach(( label_id ) => {
247
                window.location = "/cgi-bin/koha/labels/label-edit-batch.pl?op=remove&amp;batch_id=[% batch_id | html %]&amp;" + getstr;
254
                    batch_remove_form.append('<input type="hidden" name="label_id" value="' + label_id + '" />');
255
                });
256
                batch_remove_form.submit();
248
            } else {
257
            } else {
249
                return; // abort delete
258
                return; // abort delete
250
            }
259
            }
251
        }
260
        }
261
252
        function Add() {
262
        function Add() {
253
            var number_list = document.getElementById("number_list");
263
            var number_list = document.getElementById("number_list");
254
            if (number_list.value == '') {
264
            if (number_list.value == '') {
(-)a/labels/label-edit-batch.pl (-6 / +1 lines)
Lines 67-73 $number_list = $cgi->param('number_list') if $cgi->param('number_list'); Link Here
67
67
68
my $branch_code = C4::Context->userenv->{'branch'};
68
my $branch_code = C4::Context->userenv->{'branch'};
69
69
70
if ($op eq 'remove') {
70
if ($op eq 'cud-delete') {
71
    $batch = C4::Labels::Batch->retrieve(batch_id => $batch_id);
71
    $batch = C4::Labels::Batch->retrieve(batch_id => $batch_id);
72
    foreach my $label_id (@label_ids) {
72
    foreach my $label_id (@label_ids) {
73
    $err = $batch->remove_item($label_id);
73
    $err = $batch->remove_item($label_id);
Lines 77-86 if ($op eq 'remove') { Link Here
77
#    print $cgi->redirect("label-edit-batch.pl?op=edit&batch_id=$batch_id");
77
#    print $cgi->redirect("label-edit-batch.pl?op=edit&batch_id=$batch_id");
78
#    exit;
78
#    exit;
79
}
79
}
80
elsif ($op eq 'cud-delete') {
81
    $err = C4::Labels::Batch::delete(batch_id => $batch_id, branch_code => $branch_code);
82
    $errtype = 'BATCH_NOT_DELETED' if $err;
83
}
84
elsif ($op eq 'cud-add') {
80
elsif ($op eq 'cud-add') {
85
    if ($number_list) {
81
    if ($number_list) {
86
        my @numbers_list = split /\n/, $number_list; # Entries are effectively passed in as a <cr> separated list
82
        my @numbers_list = split /\n/, $number_list; # Entries are effectively passed in as a <cr> separated list
87
- 

Return to bug 37206