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 (-61 / +60 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-335 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...
327
            }
325
            }
328
        }
326
        }
329
327
330
        $(document).ready(function() {
328
        $(document).ready(function () {
331
            $('.sidebar_menu a[href$="/cgi-bin/koha/labels/label-home.pl"]').addClass("current");
329
            $('.sidebar_menu a[href$="/cgi-bin/koha/labels/label-home.pl"]').addClass("current");
332
            if (has_entries){
330
            if (has_entries) {
333
                $("#description").show();
331
                $("#description").show();
334
            } else {
332
            } else {
335
                $("#description").hide();
333
                $("#description").hide();
Lines 340-404 Link Here
340
                order: [[0, "asc"]],
338
                order: [[0, "asc"]],
341
                pagingType: "full",
339
                pagingType: "full",
342
            });
340
            });
343
            $("#additems").click(function(){
341
            $("#additems").click(function () {
344
                Add();
342
                Add();
345
                return false;
343
                return false;
346
            });
344
            });
347
            $("#removeitems").click(function(){
345
            $("#removeitems").click(function () {
348
                Remove();
346
                Remove();
349
                return false;
347
                return false;
350
            });
348
            });
351
349
352
            $("#deduplicate").click(function(){
350
            $("#deduplicate").click(function () {
353
                DeDuplicate();
351
                DeDuplicate();
354
                return false;
352
                return false;
355
            });
353
            });
356
            $("#exportitems").click(function(){
354
            $("#exportitems").click(function () {
357
                Xport('label');
355
                Xport("label");
358
                return false;
356
                return false;
359
            });
357
            });
360
            $("#exportbatch").click(function(){
358
            $("#exportbatch").click(function () {
361
                Xport('batch');
359
                Xport("batch");
362
                return false;
360
                return false;
363
            });
361
            });
364
            $(".delete").on("click", function(){
362
            $(".delete").on("click", function () {
365
                return confirmDelete( _("Are you sure you want to delete this?") );
363
                return confirmDelete(_("Are you sure you want to delete this?"));
366
            });
364
            });
367
            $(".export").on("click", function(e){
365
            $(".export").on("click", function (e) {
368
                e.preventDefault();
366
                e.preventDefault();
369
                var label_id = $(this).data("label-id");
367
                var label_id = $(this).data("label-id");
370
                var batch_id = $(this).data("batch-id");
368
                var batch_id = $(this).data("batch-id");
371
                location.href = "/cgi-bin/koha/labels/label-print.pl?batch_id=" + batch_id + "&label_id=" + label_id;
369
                location.href = "/cgi-bin/koha/labels/label-print.pl?batch_id=" + batch_id + "&label_id=" + label_id;
372
            });
370
            });
373
            $("#savedesc").click(function(event){
371
            $("#savedesc").click(function (event) {
374
                event.preventDefault(); // prevent form submission
372
                event.preventDefault(); // prevent form submission
375
                var newdescription = $('input[name="description"]').val();
373
                var newdescription = $('input[name="description"]').val();
376
                var batch_id = $(this).data('batch_id');
374
                var batch_id = $(this).data("batch_id");
377
                var ajaxData = {
375
                var ajaxData = {
378
                    'newdescription': newdescription,
376
                    newdescription: newdescription,
379
                    'batch_id': batch_id,
377
                    batch_id: batch_id,
380
                    op: 'cud-set_permission',
378
                    op: "cud-set_permission",
381
                    csrf_token: $('meta[name="csrf-token"]').attr("content"),
379
                    csrf_token: $('meta[name="csrf-token"]').attr("content"),
382
                };
380
                };
383
381
384
                $.ajax({
382
                $.ajax({
385
                    url: '/cgi-bin/koha/svc/creator_batches',
383
                    url: "/cgi-bin/koha/svc/creator_batches",
386
                    type: 'POST',
384
                    type: "POST",
387
                    dataType: 'json',
385
                    dataType: "json",
388
                    data: ajaxData,
386
                    data: ajaxData,
389
                })
387
                })
390
                .done(function(data){
388
                    .done(function (data) {
391
                    if (data.status == 'success') {
389
                        if (data.status == "success") {
392
                        $("input[name='description']").text(data.newdesc);
390
                            $("input[name='description']").text(data.newdesc);
393
                        $("#change-status").text(_("Saved"));
391
                            $("#change-status").text(_("Saved"));
394
                    } else {
392
                        } else {
393
                            $("#change-status").text(_("Unable to save description"));
394
                        }
395
                    })
396
                    .fail(function () {
395
                        $("#change-status").text(_("Unable to save description"));
397
                        $("#change-status").text(_("Unable to save description"));
396
                    }
398
                    });
397
                }).fail(function(){
398
                    $("#change-status").text(_("Unable to save description"));
399
                });
400
            });
399
            });
401
         });
400
        });
402
    </script>
401
    </script>
403
[% END %]
402
[% END %]
404
403
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/labels/label-manage.tt (-16 / +13 lines)
Lines 159-195 Link Here
159
    [% INCLUDE 'datatables.inc' %]
159
    [% INCLUDE 'datatables.inc' %]
160
    <script>
160
    <script>
161
        function Xport() {
161
        function Xport() {
162
            batches= new Array;
162
            batches = new Array();
163
            if(document.layouts.action.length > 0) {
163
            if (document.layouts.action.length > 0) {
164
                for (var i=0; i < document.layouts.action.length; i++) {
164
                for (var i = 0; i < document.layouts.action.length; i++) {
165
                    if (document.layouts.action[i].checked) {
165
                    if (document.layouts.action[i].checked) {
166
                        batches.push("batch_id=" +  document.layouts.action[i].value);
166
                        batches.push("batch_id=" + document.layouts.action[i].value);
167
                    }
167
                    }
168
                }
168
                }
169
                if (batches.length < 1) {
169
                if (batches.length < 1) {
170
                    alert(_("Please select at least one batch to export."));
170
                    alert(_("Please select at least one batch to export."));
171
                    return;     // no batch selected
171
                    return; // no batch selected
172
                }
172
                }
173
                getstr = batches.join("&");
173
                getstr = batches.join("&");
174
            }
174
            } else if (document.layouts.action.checked) {
175
            else if (document.layouts.action.checked) {
175
                getstr = "batch_id=" + document.layouts.action.value;
176
                getstr = "batch_id="+document.layouts.action.value;
176
            } else {
177
            }
178
            else {
179
                alert(_("Please select at least one batch to export."));
177
                alert(_("Please select at least one batch to export."));
180
                return;     // no batch selected
178
                return; // no batch selected
181
            }
179
            }
182
            location.href = "/cgi-bin/koha/labels/label-print.pl?" + getstr;
180
            location.href = "/cgi-bin/koha/labels/label-print.pl?" + getstr;
183
        }
181
        }
184
182
185
        $(document).ready(function(){
183
        $(document).ready(function () {
186
            $('.sidebar_menu a[href$="/cgi-bin/koha/labels/label-home.pl"]').addClass("current");
184
            $('.sidebar_menu a[href$="/cgi-bin/koha/labels/label-home.pl"]').addClass("current");
187
            $("#print").click(function(e){
185
            $("#print").click(function (e) {
188
                e.preventDefault();
186
                e.preventDefault();
189
                Xport();
187
                Xport();
190
            });
188
            });
191
            $(".delete").on("click", function(){
189
            $(".delete").on("click", function () {
192
                return confirmDelete( _("Are you sure you want to delete this?") );
190
                return confirmDelete(_("Are you sure you want to delete this?"));
193
            });
191
            });
194
            $("#labels-table").kohaTable({
192
            $("#labels-table").kohaTable({
195
                dom: '<"dt-info"i><"top pager"<"table_entries"lp><"table_controls"f>>tr<"bottom pager"ip>',
193
                dom: '<"dt-info"i><"top pager"<"table_entries"lp><"table_controls"f>>tr<"bottom pager"ip>',
196
- 

Return to bug 41571