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

(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/labels/label-edit-batch.tt (-67 / +66 lines)
Lines 235-277 Link Here
235
        const batch_id = "[% batch_id | html %]";
235
        const batch_id = "[% batch_id | html %]";
236
        const has_entries = [% table_loop ? 1 : 0 | html %];
236
        const has_entries = [% table_loop ? 1 : 0 | html %];
237
    </script>
237
    </script>
238
239
    <script>
238
    <script>
240
        function dofocus() {    // named function req'd for body onload event by some FF and IE7 security models
239
        function dofocus() {
240
            // named function req'd for body onload event by some FF and IE7 security models
241
            $(".focus:last").select();
241
            $(".focus:last").select();
242
        }
242
        }
243
        function verifyBarcodes(barcodes) {
243
        function verifyBarcodes(barcodes) {
244
            if (barcodes.value == '') {
244
            if (barcodes.value == "") {
245
                alert(_("Please add barcodes using either the direct entry text area or the item search."));
245
                alert(_("Please add barcodes using either the direct entry text area or the item search."));
246
                return false;   // not ok
246
                return false; // not ok
247
            }
247
            } else {
248
            else {
248
                return true; // ok
249
                return true;    // ok
250
            }
249
            }
251
        }
250
        }
252
251
253
        function Remove() {
252
        function Remove() {
254
            const batch_remove_form = $("#batch_remove_form");
253
            const batch_remove_form = $("#batch_remove_form");
255
            items = new Array;
254
            items = new Array();
256
            item_num = new Array;
255
            item_num = new Array();
257
            if(document.items.action.length > 0) {
256
            if (document.items.action.length > 0) {
258
                for (var i=0; i < document.items.action.length; i++) {
257
                for (var i = 0; i < document.items.action.length; i++) {
259
                    if (document.items.action[i].checked) {
258
                    if (document.items.action[i].checked) {
260
                        items.push( document.items.action[i].value );
259
                        items.push(document.items.action[i].value);
261
                        item_num.push( i + 1 );
260
                        item_num.push(i + 1);
262
                    }
261
                    }
263
                }
262
                }
264
                item_msg = item_num.join(", ");
263
                item_msg = item_num.join(", ");
265
                var msg = _("Are you sure you want to remove label number(s): %s from this batch?").format(item_msg);
264
                var msg = _("Are you sure you want to remove label number(s): %s from this batch?").format(item_msg);
266
            } else if (document.items.action.checked) {
265
            } else if (document.items.action.checked) {
267
                alert(_("Deletion of label from a batch with only one label will delete the batch.") + "\n\n" + _("If this is what you want, select the 'Delete batch' option from the toolbar"));
266
                alert(_("Deletion of label from a batch with only one label will delete the batch.") + "\n\n" + _("If this is what you want, select the 'Delete batch' option from the toolbar"));
268
                    return; // no deletion for single item batch
267
                return; // no deletion for single item batch
269
            } else {
268
            } else {
270
                alert(_("Please select at least one label to delete."));
269
                alert(_("Please select at least one label to delete."));
271
                return;     // no item selected
270
                return; // no item selected
272
            }
271
            }
273
            if ( confirm( msg ) ) {
272
            if (confirm(msg)) {
274
                items.forEach(( label_id ) => {
273
                items.forEach(label_id => {
275
                    batch_remove_form.append('<input type="hidden" name="label_id" value="' + label_id + '" />');
274
                    batch_remove_form.append('<input type="hidden" name="label_id" value="' + label_id + '" />');
276
                });
275
                });
277
                batch_remove_form.submit();
276
                batch_remove_form.submit();
Lines 282-297 Link Here
282
281
283
        function Add() {
282
        function Add() {
284
            var number_list = document.getElementById("number_list");
283
            var number_list = document.getElementById("number_list");
285
            if (number_list.value == '') {
284
            if (number_list.value == "") {
286
                window.open("/cgi-bin/koha/labels/label-item-search.pl?batch_id=" + batch_id + "&amp;type=labels",'FindABibIndex','width=875,height=400,toolbar=no,scrollbars=yes');
285
                window.open("/cgi-bin/koha/labels/label-item-search.pl?batch_id=" + batch_id + "&amp;type=labels", "FindABibIndex", "width=875,height=400,toolbar=no,scrollbars=yes");
287
            } else {
286
            } else {
288
                document.forms["add_by_number"].submit();
287
                document.forms["add_by_number"].submit();
289
            }
288
            }
290
        }
289
        }
291
290
292
        function add_item(item_number) {
291
        function add_item(item_number) {
293
            $("#itemnum_enter").prop("checked",true);
292
            $("#itemnum_enter").prop("checked", true);
294
            $("#number_list").val($("#number_list").val()+item_number+"\r\n");
293
            $("#number_list").val($("#number_list").val() + item_number + "\r\n");
295
        }
294
        }
296
295
297
        function DeDuplicate() {
296
        function DeDuplicate() {
Lines 299-326 Link Here
299
        }
298
        }
300
299
301
        function Xport(mode) {
300
        function Xport(mode) {
302
            if (mode == 'label') {
301
            if (mode == "label") {
303
                labels= new Array;
302
                labels = new Array();
304
                if(document.items.action.length > 0) {
303
                if (document.items.action.length > 0) {
305
                    for (var i=0; i < document.items.action.length; i++) {
304
                    for (var i = 0; i < document.items.action.length; i++) {
306
                        if (document.items.action[i].checked) {
305
                        if (document.items.action[i].checked) {
307
                            labels.push("label_id=" +  document.items.action[i].value);
306
                            labels.push("label_id=" + document.items.action[i].value);
308
                        }
307
                        }
309
                    }
308
                    }
310
                    if (labels.length < 1) {
309
                    if (labels.length < 1) {
311
                        alert(_("Please select at least one label to export."));
310
                        alert(_("Please select at least one label to export."));
312
                        return;     // no batch selected
311
                        return; // no batch selected
313
                    }
312
                    }
314
                    getstr = labels.join("&");
313
                    getstr = labels.join("&");
315
                }
314
                } else if (document.items.action.checked) {
316
                else if (document.items.action.checked) {
317
                    getstr = document.items.action.value;
315
                    getstr = document.items.action.value;
318
                } else {
316
                } else {
319
                    alert(_("Please select at least one label to export."));
317
                    alert(_("Please select at least one label to export."));
320
                    return;     // no batch selected
318
                    return; // no batch selected
321
                }
319
                }
322
                location.href = "/cgi-bin/koha/labels/label-print.pl?batch_id=" + batch_id + "&" + getstr;
320
                location.href = "/cgi-bin/koha/labels/label-print.pl?batch_id=" + batch_id + "&" + getstr;
323
            } else if (mode == 'batch') {
321
            } else if (mode == "batch") {
324
                location.href = "/cgi-bin/koha/labels/label-print.pl?batch_id=" + batch_id;
322
                location.href = "/cgi-bin/koha/labels/label-print.pl?batch_id=" + batch_id;
325
            } else {
323
            } else {
326
                // some pass-through error trapping just in case...
324
                // some pass-through error trapping just in case...
Lines 329-351 Link Here
329
327
330
        function selected_layout() {
328
        function selected_layout() {
331
            if (document.items.action.length) {
329
            if (document.items.action.length) {
332
                for (i=0;i<document.items.action.length;i++){
330
                for (i = 0; i < document.items.action.length; i++) {
333
                    if (document.items.action[i].checked==true){
331
                    if (document.items.action[i].checked == true) {
334
                        return(document.items.action[i].value);
332
                        return document.items.action[i].value;
335
                    }
333
                    }
336
                }
334
                }
337
            } else {
335
            } else {
338
                if (document.items.action.checked){
336
                if (document.items.action.checked) {
339
                    return(document.items.action.value);
337
                    return document.items.action.value;
340
                }
338
                }
341
            }
339
            }
342
            alert(_("Please select at least one item."));
340
            alert(_("Please select at least one item."));
343
            return (-1);
341
            return -1;
344
        }
342
        }
345
343
346
        $(document).ready(function() {
344
        $(document).ready(function () {
347
            $('.sidebar_menu a[href$="/cgi-bin/koha/labels/label-home.pl"]').addClass("current");
345
            $('.sidebar_menu a[href$="/cgi-bin/koha/labels/label-home.pl"]').addClass("current");
348
            if (has_entries){
346
            if (has_entries) {
349
                $("#description").show();
347
                $("#description").show();
350
            } else {
348
            } else {
351
                $("#description").hide();
349
                $("#description").hide();
Lines 356-420 Link Here
356
                order: [[0, "asc"]],
354
                order: [[0, "asc"]],
357
                pagingType: "full",
355
                pagingType: "full",
358
            });
356
            });
359
            $("#additems").click(function(){
357
            $("#additems").click(function () {
360
                Add();
358
                Add();
361
                return false;
359
                return false;
362
            });
360
            });
363
            $("#removeitems").click(function(){
361
            $("#removeitems").click(function () {
364
                Remove();
362
                Remove();
365
                return false;
363
                return false;
366
            });
364
            });
367
365
368
            $("#deduplicate").click(function(){
366
            $("#deduplicate").click(function () {
369
                DeDuplicate();
367
                DeDuplicate();
370
                return false;
368
                return false;
371
            });
369
            });
372
            $("#exportitems").click(function(){
370
            $("#exportitems").click(function () {
373
                Xport('label');
371
                Xport("label");
374
                return false;
372
                return false;
375
            });
373
            });
376
            $("#exportbatch").click(function(){
374
            $("#exportbatch").click(function () {
377
                Xport('batch');
375
                Xport("batch");
378
                return false;
376
                return false;
379
            });
377
            });
380
            $(".delete").on("click", function(){
378
            $(".delete").on("click", function () {
381
                return confirmDelete( _("Are you sure you want to delete this?") );
379
                return confirmDelete(_("Are you sure you want to delete this?"));
382
            });
380
            });
383
            $(".export").on("click", function(e){
381
            $(".export").on("click", function (e) {
384
                e.preventDefault();
382
                e.preventDefault();
385
                var label_id = $(this).data("label-id");
383
                var label_id = $(this).data("label-id");
386
                var batch_id = $(this).data("batch-id");
384
                var batch_id = $(this).data("batch-id");
387
                location.href = "/cgi-bin/koha/labels/label-print.pl?batch_id=" + batch_id + "&label_id=" + label_id;
385
                location.href = "/cgi-bin/koha/labels/label-print.pl?batch_id=" + batch_id + "&label_id=" + label_id;
388
            });
386
            });
389
            $("#savedesc").click(function(event){
387
            $("#savedesc").click(function (event) {
390
                event.preventDefault(); // prevent form submission
388
                event.preventDefault(); // prevent form submission
391
                var newdescription = $('input[name="description"]').val();
389
                var newdescription = $('input[name="description"]').val();
392
                var batch_id = $(this).data('batch_id');
390
                var batch_id = $(this).data("batch_id");
393
                var ajaxData = {
391
                var ajaxData = {
394
                    'newdescription': newdescription,
392
                    newdescription: newdescription,
395
                    'batch_id': batch_id,
393
                    batch_id: batch_id,
396
                    op: 'cud-set_permission',
394
                    op: "cud-set_permission",
397
                    csrf_token: $('meta[name="csrf-token"]').attr("content"),
395
                    csrf_token: $('meta[name="csrf-token"]').attr("content"),
398
                };
396
                };
399
397
400
                $.ajax({
398
                $.ajax({
401
                    url: '/cgi-bin/koha/svc/creator_batches',
399
                    url: "/cgi-bin/koha/svc/creator_batches",
402
                    type: 'POST',
400
                    type: "POST",
403
                    dataType: 'json',
401
                    dataType: "json",
404
                    data: ajaxData,
402
                    data: ajaxData,
405
                })
403
                })
406
                .done(function(data){
404
                    .done(function (data) {
407
                    if (data.status == 'success') {
405
                        if (data.status == "success") {
408
                        $("input[name='description']").text(data.newdesc);
406
                            $("input[name='description']").text(data.newdesc);
409
                        $("#change-status").text(_("Saved"));
407
                            $("#change-status").text(_("Saved"));
410
                    } else {
408
                        } else {
409
                            $("#change-status").text(_("Unable to save description"));
410
                        }
411
                    })
412
                    .fail(function () {
411
                        $("#change-status").text(_("Unable to save description"));
413
                        $("#change-status").text(_("Unable to save description"));
412
                    }
414
                    });
413
                }).fail(function(){
414
                    $("#change-status").text(_("Unable to save description"));
415
                });
416
            });
415
            });
417
         });
416
        });
418
    </script>
417
    </script>
419
[% END %]
418
[% END %]
420
419
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/labels/label-manage.tt (-2 lines)
Lines 161-167 Link Here
161
        // FIXME This is impossible to translate correctly
161
        // FIXME This is impossible to translate correctly
162
        const label_element = "[% label_element | html %]";
162
        const label_element = "[% label_element | html %]";
163
    </script>
163
    </script>
164
165
    <script>
164
    <script>
166
        function Xport() {
165
        function Xport() {
167
            batches= new Array;
166
            batches= new Array;
168
- 

Return to bug 41571