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

(-)a/koha-tmpl/opac-tmpl/bootstrap/en/modules/sco/sco-main.tt (-102 / +117 lines)
Lines 406-526 Link Here
406
    [% BLOCK jsinclude %]
406
    [% BLOCK jsinclude %]
407
        [% INCLUDE 'datatables.inc' %]
407
        [% INCLUDE 'datatables.inc' %]
408
        <script>
408
        <script>
409
            function mungeHistory() {
409
            addPrefs({
410
                    // prevent back button from allowing form resubmission
410
                SelfCheckTimeout: "[% Koha.Preference('SelfCheckTimeout') | html %]",
411
                    if (history && history.pushState) {
411
                SelfCheckReceiptPrompt: [% Koha.Preference('SelfCheckReceiptPrompt') ? 1 : 0 | html %],
412
                        history.replaceState(null, document.title, window.location.href);
412
            });
413
            const logged_in_user_cardnumber = "[% patronid | html %]";
414
        </script>
415
        [% IF Koha.Preference('AudioAlerts') %]
416
            <script>
417
                var AUDIO_ALERTS = JSON.parse( "[% To.json(AudioAlerts.AudioAlerts) | $raw %]" );
418
                $( document ).ready(function() {
419
                    if ( AUDIO_ALERTS ) {
420
                        for ( var k in AUDIO_ALERTS ) {
421
                            var alert = AUDIO_ALERTS[k];
422
                            if ( $( alert.selector ).length ) {
423
                                playSound( alert.sound );
424
                                break;
425
                            }
426
                        }
413
                    }
427
                    }
428
                });
429
                function playSound( sound ) {
430
                    if (!(sound.indexOf("http://") === 0 || sound.indexOf("https://") === 0)) {
431
                        sound = '[% interface | html %]' + '/bootstrap/sound/' + sound;
432
                    }
433
                    document.getElementById("audio-alert").innerHTML = '<audio src="' + sound + '" autoplay="autoplay" autobuffer="autobuffer"></audio>';
414
                }
434
                }
415
                var mainTimeout;
435
            </script>
416
                function sco_init() {
436
        [% END %]
417
                    mainTimeout = setTimeout(function() {
437
        <script>
418
                        location.href = '/cgi-bin/koha/sco/sco-main.pl?op=logout';
438
            function mungeHistory() {
419
                    }, [% SelfCheckTimeout | html %]);
439
                // prevent back button from allowing form resubmission
440
                if (history && history.pushState) {
441
                    history.replaceState(null, document.title, window.location.href);
420
                }
442
                }
421
                function dofocus() {    // named function req'd for body onload event by some FF and IE7 security models
443
            }
422
                    // alert("dofocus called");
444
            var mainTimeout;
423
                    $(".focus:last").select();
445
            function sco_init() {
446
                mainTimeout = setTimeout(function () {
447
                    location.href = "/cgi-bin/koha/sco/sco-main.pl?op=logout";
448
                }, prefs.SelfCheckTimeout);
449
            }
450
            function dofocus() {
451
                // named function req'd for body onload event by some FF and IE7 security models
452
                // alert("dofocus called");
453
                $(".focus:last").select();
454
            }
455
            var slip_re = /slip/;
456
            function printx_window(print_type) {
457
                var handler = print_type.match(slip_re) ? "printslip" : "moremember";
458
459
                return false;
460
            }
461
            function checkout_confirm(patronid) {
462
                var barcode = $("#barcode").val();
463
                // alert("checkout_confirm('" + patronid + "') called for barcode '" + barcode + "'");
464
                if (!barcode) {
465
                    dofocus();
466
                    return false;
467
                } // no barcode
468
                if (barcode == "__KOHA_NEW_CIRC__") {
469
                    // magic barcode
470
                    window.location.href = "/cgi-bin/koha/sco/sco-main.pl?op=logout";
471
                    return false;
424
                }
472
                }
425
                var slip_re = /slip/;
473
                return true;
426
                function printx_window(print_type) {
474
            }
427
                  var handler = print_type.match(slip_re) ? "printslip" : "moremember";
428
475
429
                  return false;
476
            $(window).on("load", function () {
430
                }
477
                dofocus();
431
                function checkout_confirm(patronid) {
478
            });
432
                    var   barcode = $("#barcode").val();
479
433
                    // alert("checkout_confirm('" + patronid + "') called for barcode '" + barcode + "'");
480
            $(window).on("unload", function () {
434
                    if (! barcode) { dofocus(); return false; }    // no barcode
481
                mungeHistory();
435
                    if (barcode == "__KOHA_NEW_CIRC__") {   // magic barcode
482
            });
436
                        window.location.href='/cgi-bin/koha/sco/sco-main.pl?op=logout';
483
437
                        return false;
484
            $(document).ready(function () {
438
                    }
485
                dofocus();
439
                    return true;
486
                if (logged_in_user_cardnumber) {
487
                    sco_init();
440
                }
488
                }
441
                [% IF Koha.Preference('AudioAlerts') %]
442
                    var AUDIO_ALERTS = JSON.parse( "[% To.json(AudioAlerts.AudioAlerts) | $raw %]" );
443
                    $( document ).ready(function() {
444
                        if ( AUDIO_ALERTS ) {
445
                            for ( var k in AUDIO_ALERTS ) {
446
                                var alert = AUDIO_ALERTS[k];
447
                                if ( $( alert.selector ).length ) {
448
                                    playSound( alert.sound );
449
                                    break;
450
                                }
451
                            }
452
                        }
453
                    });
454
                    function playSound( sound ) {
455
                        if (!(sound.indexOf("http://") === 0 || sound.indexOf("https://") === 0)) {
456
                            sound = '[% interface | html %]' + '/bootstrap/sound/' + sound;
457
                        }
458
                        document.getElementById("audio-alert").innerHTML = '<audio src="' + sound + '" autoplay="autoplay" autobuffer="autobuffer"></audio>';
459
                    }
460
                [% END %]
461
489
462
                $( window ).on( "load", function() {
490
                var dTables = $("#loanTable, #holdst, #finestable");
463
                    dofocus();
491
                dTables.each(function () {
492
                    var thIndex = $(this).find("th.psort").index();
493
                    $(this).kohaTable({
494
                        order: [[thIndex, "asc"]],
495
                        dom: '<"top"<"table_entries"><"table_controls"f>>t<"clear">',
496
                        columnDefs: [
497
                            { targets: ["noshow"], visible: false, searchable: false },
498
                            { visible: false, targets: ["hidden"] },
499
                            { className: "dtr-control", orderable: false, targets: -1 },
500
                        ],
501
                        language: {
502
                            search: "_INPUT_",
503
                            searchPlaceholder: _("Search"),
504
                        },
505
                        responsive: {
506
                            details: {
507
                                type: "column",
508
                                target: -1,
509
                            },
510
                        },
511
                    });
464
                });
512
                });
465
513
466
                $( window ).on( "unload", function() {
514
                $('a[data-bs-toggle="tab"]').on("shown.bs.tab", function (event) {
467
                    mungeHistory();
515
                    dTables.DataTable().responsive.recalc();
468
                });
516
                });
469
517
470
                $(document).ready(function() {
518
                $("#logout_form").on("click", function (e) {
471
                    dofocus();
519
                    e.preventDefault(e);
472
                    [% IF ( patronid ) %]sco_init();[% END %]
520
                    clearTimeout(mainTimeout);
473
521
                    if (prefs.SelfCheckReceiptPrompt) {
474
                    var dTables = $("#loanTable, #holdst, #finestable");
522
                        confirmModal("", _("Would you like to print a receipt?"), _("Print receipt and end session"), _("End session"), function (result) {
475
                    dTables.each(function(){
523
                            if (result) {
476
                        var thIndex = $(this).find("th.psort").index();
524
                                var win = window.open("/cgi-bin/koha/sco/printslip.pl?print=qslip");
477
                        $(this).kohaTable({
525
                                location.href = "/cgi-bin/koha/sco/sco-main.pl?op=logout";
478
                            order: [[thIndex, "asc"]],
526
                            } else {
479
                            dom: '<"top"<"table_entries"><"table_controls"f>>t<"clear">',
527
                                location.href = "/cgi-bin/koha/sco/sco-main.pl?op=logout";
480
                            columnDefs: [
528
                            }
481
                                { targets: ["noshow"], visible: false, searchable: false },
482
                                { visible: false, targets: ["hidden"] },
483
                                { className: "dtr-control", orderable: false, targets: -1 },
484
                            ],
485
                            language: {
486
                                search: "_INPUT_",
487
                                searchPlaceholder: _("Search"),
488
                            },
489
                            responsive: {
490
                                details: {
491
                                    type: "column",
492
                                    target: -1,
493
                                },
494
                            },
495
                        });
529
                        });
496
                    });
530
                    } else {
497
531
                        location.href = "/cgi-bin/koha/sco/sco-main.pl?op=logout";
498
                    $('a[data-bs-toggle="tab"]').on('shown.bs.tab', function (event) {
532
                    }
499
                        dTables.DataTable().responsive.recalc();
500
                    } );
501
502
                    $("#logout_form").on("click", function(e){
503
                        e.preventDefault(e);
504
                        clearTimeout(mainTimeout);
505
                        [% IF Koha.Preference('SelfCheckReceiptPrompt') %]
506
                            confirmModal("", _("Would you like to print a receipt?"), _("Print receipt and end session"), _("End session"), function(result) {
507
                                if ( result ){
508
                                    var win = window.open("/cgi-bin/koha/sco/printslip.pl?print=qslip");
509
                                    location.href = '/cgi-bin/koha/sco/sco-main.pl?op=logout';
510
                                } else {
511
                                    location.href = '/cgi-bin/koha/sco/sco-main.pl?op=logout';
512
                                }
513
                            });
514
                        [% ELSE %]
515
                            location.href = '/cgi-bin/koha/sco/sco-main.pl?op=logout';
516
                        [% END %]
517
533
518
                        return true;
534
                    return true;
519
                    });
535
                });
520
536
521
                    $("#scan_form").on("submit", function(){
537
                $("#scan_form").on("submit", function () {
522
                        return checkout_confirm('[% patronid | html %]');
538
                    return checkout_confirm(logged_in_user_cardnumber);
523
                    });
539
                });
524
            });
540
            });
525
        </script>
541
        </script>
526
        [% Asset.js("js/holds.js") | $raw %]
542
        [% Asset.js("js/holds.js") | $raw %]
527
- 

Return to bug 41582