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

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

Return to bug 41582