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

(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/patroncards/edit-batch.tt (-77 / +77 lines)
Lines 187-207 Link Here
187
            var msg = _("Are you sure you want to delete batch %s?").format(batch_id);
187
            var msg = _("Are you sure you want to delete batch %s?").format(batch_id);
188
            var answer = confirm(msg);
188
            var answer = confirm(msg);
189
            if (answer) {
189
            if (answer) {
190
                $('#batch_form input[name="op"]').val('cud-delete');
190
                $('#batch_form input[name="op"]').val("cud-delete");
191
                $('#batch_form').append( `<input type="hidden" name="element_id" value="${batch_id}" />` );
191
                $("#batch_form").append(`<input type="hidden" name="element_id" value="${batch_id}" />`);
192
                $('#batch_form').append( '<input type="hidden" name="card_element" value="batch" />' );
192
                $("#batch_form").append('<input type="hidden" name="card_element" value="batch" />');
193
                $('#batch_form').submit();
193
                $("#batch_form").submit();
194
            } else {
194
            } else {
195
                return; // abort delete
195
                return; // abort delete
196
            }
196
            }
197
        };
197
        }
198
        function Remove() {
198
        function Remove() {
199
            items = new Array;
199
            items = new Array();
200
200
201
            if(document.items.action.length > 0) {
201
            if (document.items.action.length > 0) {
202
                for (var i=0; i < document.items.action.length; i++) {
202
                for (var i = 0; i < document.items.action.length; i++) {
203
                    if (document.items.action[i].checked) {
203
                    if (document.items.action[i].checked) {
204
                        items.push( document.items.action[i].value );
204
                        items.push(document.items.action[i].value);
205
                    }
205
                    }
206
                }
206
                }
207
                getstr = items.join("&");
207
                getstr = items.join("&");
Lines 211-315 Link Here
211
                return; // no deletion for single item batch
211
                return; // no deletion for single item batch
212
            } else {
212
            } else {
213
                alert(_("Please select at least one patron to delete."));
213
                alert(_("Please select at least one patron to delete."));
214
                return;     // no item selected
214
                return; // no item selected
215
            }
215
            }
216
            var answer = confirm(msg);
216
            var answer = confirm(msg);
217
            if (answer) {
217
            if (answer) {
218
                $('#patron_form input[name="op"]').val('cud-remove');
218
                $('#patron_form input[name="op"]').val("cud-remove");
219
                $('#patron_form input[name="batch_id"]').val(batch_id);
219
                $('#patron_form input[name="batch_id"]').val(batch_id);
220
                $('#patron_form input[name="label_id"]').remove();
220
                $('#patron_form input[name="label_id"]').remove();
221
                items.forEach( (item_id) => {
221
                items.forEach(item_id => {
222
                    $('#patron_form').append( '<input type="hidden" name="label_id" value="' + item_id + '" />' );
222
                    $("#patron_form").append('<input type="hidden" name="label_id" value="' + item_id + '" />');
223
                });
223
                });
224
                $('#patron_form').submit();
224
                $("#patron_form").submit();
225
            } else {
225
            } else {
226
                return; // abort delete
226
                return; // abort delete
227
            }
227
            }
228
        };
228
        }
229
        function Add() {
229
        function Add() {
230
            var bor_nums = document.getElementById("bor_num_list");
230
            var bor_nums = document.getElementById("bor_num_list");
231
            if (bor_nums.value == '') {
231
            if (bor_nums.value == "") {
232
                return true;
232
                return true;
233
            }
233
            }
234
234
235
            document.forms["add_by_bor_num"].submit();
235
            document.forms["add_by_bor_num"].submit();
236
            return false
236
            return false;
237
        };
237
        }
238
238
239
        function add_user(borrowernumber) {
239
        function add_user(borrowernumber) {
240
            var list = $("#bor_num_list").val();
240
            var list = $("#bor_num_list").val();
241
            if (list.indexOf(borrowernumber) == -1) {
241
            if (list.indexOf(borrowernumber) == -1) {
242
                $("#bor_num_list").val(list+borrowernumber+"\r\n");
242
                $("#bor_num_list").val(list + borrowernumber + "\r\n");
243
            } else {
243
            } else {
244
                return -1;
244
                return -1;
245
            }
245
            }
246
        }
246
        }
247
247
248
        function DeDuplicate() {
248
        function DeDuplicate() {
249
            $('#patron_form input[name="op"]').val('cud-dedup');
249
            $('#patron_form input[name="op"]').val("cud-dedup");
250
            $('#patron_form input[name="batch_id"]').val(batch_id);
250
            $('#patron_form input[name="batch_id"]').val(batch_id);
251
            $('#patron_form').submit();
251
            $("#patron_form").submit();
252
        }
252
        }
253
253
254
        function Xport(mode) {
254
        function Xport(mode) {
255
            if (mode == 'label') {
255
            if (mode == "label") {
256
                patroncards= new Array;
256
                patroncards = new Array();
257
                if(document.items.action.length > 0) {
257
                if (document.items.action.length > 0) {
258
                    for (var i=0; i < document.items.action.length; i++) {
258
                    for (var i = 0; i < document.items.action.length; i++) {
259
                        if (document.items.action[i].checked) {
259
                        if (document.items.action[i].checked) {
260
                            patroncards.push("label_id=" +  document.items.action[i].value);
260
                            patroncards.push("label_id=" + document.items.action[i].value);
261
                        }
261
                        }
262
                    }
262
                    }
263
                    if (patroncards.length < 1) {
263
                    if (patroncards.length < 1) {
264
                        alert(_("Please select at least one card to export."));
264
                        alert(_("Please select at least one card to export."));
265
                        return;     // no batch selected
265
                        return; // no batch selected
266
                    }
266
                    }
267
                    getstr = patroncards.join("&");
267
                    getstr = patroncards.join("&");
268
                } else if (document.items.action.checked) {
268
                } else if (document.items.action.checked) {
269
                    getstr = document.items.action.value;
269
                    getstr = document.items.action.value;
270
                } else {
270
                } else {
271
                    alert(_("Please select at least one card to export."));
271
                    alert(_("Please select at least one card to export."));
272
                    return;     // no batch selected
272
                    return; // no batch selected
273
                }
273
                }
274
                location.href = `/cgi-bin/koha/patroncards/print.pl?batch_id=${batch_id}&${getstr}`;
274
                location.href = `/cgi-bin/koha/patroncards/print.pl?batch_id=${batch_id}&${getstr}`;
275
            } else if (mode == 'batch') {
275
            } else if (mode == "batch") {
276
                location.href = `/cgi-bin/koha/patroncards/print.pl?batch_id=${batch_id}`;
276
                location.href = `/cgi-bin/koha/patroncards/print.pl?batch_id=${batch_id}`;
277
            } else {
277
            } else {
278
                // some pass-through error trapping just in case...
278
                // some pass-through error trapping just in case...
279
            }
279
            }
280
        };
280
        }
281
        function selected_layout() {
281
        function selected_layout() {
282
            if (document.items.action.length) {
282
            if (document.items.action.length) {
283
            for (i=0;i<document.items.action.length;i++){
283
                for (i = 0; i < document.items.action.length; i++) {
284
                if (document.items.action[i].checked==true){
284
                    if (document.items.action[i].checked == true) {
285
                    return(document.items.action[i].value);
285
                        return document.items.action[i].value;
286
                    }
286
                }
287
                }
287
            };
288
            } else {
288
            } else {
289
                if (document.items.action.checked){
289
                if (document.items.action.checked) {
290
                    return(document.items.action.value);
290
                    return document.items.action.value;
291
                }
291
                }
292
            };
292
            }
293
            alert(_("Please select at least one item."));
293
            alert(_("Please select at least one item."));
294
            return (-1);
294
            return -1;
295
        };
295
        }
296
296
297
        $(document).ready(function() {
297
        $(document).ready(function () {
298
            // Prepare DataTables settings
298
            // Prepare DataTables settings
299
            var aLengthMenu = [10, 20, 50, 100, -1];
299
            var aLengthMenu = [10, 20, 50, 100, -1];
300
            var aLengthMenuLabel = [10, 20, 50, 100, _("All")];
300
            var aLengthMenuLabel = [10, 20, 50, 100, _("All")];
301
            for ( var i = 0; i < aLengthMenu.length; i++ ) {
301
            for (var i = 0; i < aLengthMenu.length; i++) {
302
                if ( aLengthMenu[i] == prefs.PatronsPerPage ) {
302
                if (aLengthMenu[i] == prefs.PatronsPerPage) {
303
                    break;
303
                    break;
304
                }
304
                }
305
                if ( aLengthMenu[i] > prefs.PatronsPerPage || aLengthMenu[i] == -1 ) {
305
                if (aLengthMenu[i] > prefs.PatronsPerPage || aLengthMenu[i] == -1) {
306
                    aLengthMenu.splice(i, 0, prefs.PatronsPerPage);
306
                    aLengthMenu.splice(i, 0, prefs.PatronsPerPage);
307
                    aLengthMenuLabel.splice(i, 0, prefs.PatronsPerPage);
307
                    aLengthMenuLabel.splice(i, 0, prefs.PatronsPerPage);
308
                    break;
308
                    break;
309
                }
309
                }
310
            }
310
            }
311
311
312
            if (has_entries){
312
            if (has_entries) {
313
                $("#description").show();
313
                $("#description").show();
314
            } else {
314
            } else {
315
                $("#description").hide();
315
                $("#description").hide();
Lines 322-393 Link Here
322
                pageLength: prefs.PatronsPerPage,
322
                pageLength: prefs.PatronsPerPage,
323
                autoWidth: false,
323
                autoWidth: false,
324
            });
324
            });
325
            $("#additems").click(function(){
325
            $("#additems").click(function () {
326
                return Add();
326
                return Add();
327
            });
327
            });
328
            $("#removeitems").click(function(){
328
            $("#removeitems").click(function () {
329
                Remove();
329
                Remove();
330
                return false;
330
                return false;
331
            });
331
            });
332
            $("#deletebatch").click(function(){
332
            $("#deletebatch").click(function () {
333
                DeleteConfirm();
333
                DeleteConfirm();
334
                return false;
334
                return false;
335
            });
335
            });
336
            $("#deduplicate").click(function(){
336
            $("#deduplicate").click(function () {
337
                DeDuplicate();
337
                DeDuplicate();
338
                return false;
338
                return false;
339
            });
339
            });
340
            $("#exportitems").click(function(){
340
            $("#exportitems").click(function () {
341
                Xport('label');
341
                Xport("label");
342
                return false;
342
                return false;
343
            });
343
            });
344
            $("#exportbatch").click(function(){
344
            $("#exportbatch").click(function () {
345
                Xport('batch');
345
                Xport("batch");
346
                return false;
346
                return false;
347
            });
347
            });
348
            $(".delete").on("click", function(){
348
            $(".delete").on("click", function () {
349
                if( confirmDelete( _("Are you sure you want to delete this patron from the card batch?") ) ) {
349
                if (confirmDelete(_("Are you sure you want to delete this patron from the card batch?"))) {
350
                    $('#patron_form input[name="op"]').val('cud-remove');
350
                    $('#patron_form input[name="op"]').val("cud-remove");
351
                    $('#patron_form input[name="batch_id"]').val($(this).data('batch-id'));
351
                    $('#patron_form input[name="batch_id"]').val($(this).data("batch-id"));
352
                    $('#patron_form input[name="label_id"]').val($(this).data('label-id'));
352
                    $('#patron_form input[name="label_id"]').val($(this).data("label-id"));
353
                    $('#patron_form').submit();
353
                    $("#patron_form").submit();
354
                }
354
                }
355
            });
355
            });
356
            $(".export").on("click", function(e){
356
            $(".export").on("click", function (e) {
357
                e.preventDefault();
357
                e.preventDefault();
358
                var label_id = $(this).data("label-id");
358
                var label_id = $(this).data("label-id");
359
                var batch_id = $(this).data("batch-id");
359
                var batch_id = $(this).data("batch-id");
360
                location.href = "/cgi-bin/koha/patroncards/print.pl?batch_id=" + batch_id + "&label_id=" + label_id;
360
                location.href = "/cgi-bin/koha/patroncards/print.pl?batch_id=" + batch_id + "&label_id=" + label_id;
361
            });
361
            });
362
362
363
            $("#savedesc").click(function(event){
363
            $("#savedesc").click(function (event) {
364
                event.preventDefault(); // prevent form submission
364
                event.preventDefault(); // prevent form submission
365
                var newdescription = $('input[name="description"]').val();
365
                var newdescription = $('input[name="description"]').val();
366
                var batch_id = $(this).data('batch_id');
366
                var batch_id = $(this).data("batch_id");
367
                var ajaxData = {
367
                var ajaxData = {
368
                    'newdescription': newdescription,
368
                    newdescription: newdescription,
369
                    'batch_id': batch_id,
369
                    batch_id: batch_id,
370
                    op: 'cud-set_permission',
370
                    op: "cud-set_permission",
371
                    csrf_token: $('meta[name="csrf-token"]').attr("content"),
371
                    csrf_token: $('meta[name="csrf-token"]').attr("content"),
372
                };
372
                };
373
373
374
                $.ajax({
374
                $.ajax({
375
                    url: '/cgi-bin/koha/svc/creator_batches',
375
                    url: "/cgi-bin/koha/svc/creator_batches",
376
                    type: 'POST',
376
                    type: "POST",
377
                    dataType: 'json',
377
                    dataType: "json",
378
                    data: ajaxData,
378
                    data: ajaxData,
379
                })
379
                })
380
380
381
                .done(function(data){
381
                    .done(function (data) {
382
                    if (data.status == 'success') {
382
                        if (data.status == "success") {
383
                        $("input[name='description']").text(data.newdesc);
383
                            $("input[name='description']").text(data.newdesc);
384
                        $("#change-status").text(_("Saved"));
384
                            $("#change-status").text(_("Saved"));
385
                    } else {
385
                        } else {
386
                            $("#change-status").text(_("Unable to save description"));
387
                        }
388
                    })
389
                    .fail(function () {
386
                        $("#change-status").text(_("Unable to save description"));
390
                        $("#change-status").text(_("Unable to save description"));
387
                    }
391
                    });
388
                }).fail(function(){
389
                    $("#change-status").text(_("Unable to save description"));
390
                });
391
            });
392
            });
392
        });
393
        });
393
    </script>
394
    </script>
394
- 

Return to bug 41574