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

(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/article-requests.tt (-125 / +140 lines)
Lines 531-587 Link Here
531
        const interface = "[% interface | html %]";
531
        const interface = "[% interface | html %]";
532
        const theme = "[% theme | html %]";
532
        const theme = "[% theme | html %]";
533
    </script>
533
    </script>
534
535
    <script>
534
    <script>
536
        var active_tab = "#article-requests-requested_panel";
535
        var active_tab = "#article-requests-requested_panel";
537
        var last_cancel_reason, requested_datatable, pending_datatable, processing_datatable, active_datatable, requested_dt, pending_dt, processing_dt;
536
        var last_cancel_reason, requested_datatable, pending_datatable, processing_datatable, active_datatable, requested_dt, pending_dt, processing_dt;
538
        $(document).ready(function() {
537
        $(document).ready(function () {
539
540
            $("#article-request-tabs a[data-bs-toggle='tab']").on("shown.bs.tab", function (e) {
538
            $("#article-request-tabs a[data-bs-toggle='tab']").on("shown.bs.tab", function (e) {
541
                active_tab = e.target.hash;
539
                active_tab = e.target.hash;
542
                if( active_tab == "#article-requests-requested_panel" ){
540
                if (active_tab == "#article-requests-requested_panel") {
543
                    active_datatable = requested_datatable;
541
                    active_datatable = requested_datatable;
544
                } else if( active_tab == "#article-requests-pending_panel" ){
542
                } else if (active_tab == "#article-requests-pending_panel") {
545
                    active_datatable = pending_datatable;
543
                    active_datatable = pending_datatable;
546
                } else {
544
                } else {
547
                    active_datatable = processing_datatable;
545
                    active_datatable = processing_datatable;
548
                }
546
                }
549
                activateBatchActions( active_tab );
547
                activateBatchActions(active_tab);
550
            });
548
            });
551
549
552
            $( "input:checkbox, #article-request-tabs" ).on("change", function(){
550
            $("input:checkbox, #article-request-tabs").on("change", function () {
553
                activateBatchActions( active_tab );
551
                activateBatchActions(active_tab);
554
            });
552
            });
555
553
556
            $(".SelectAll").on("click", function(e) {
554
            $(".SelectAll").on("click", function (e) {
557
                e.preventDefault();
555
                e.preventDefault();
558
                $( active_tab + " input[type='checkbox']").prop('checked', true);
556
                $(active_tab + " input[type='checkbox']").prop("checked", true);
559
                activateBatchActions( active_tab );
557
                activateBatchActions(active_tab);
560
            });
558
            });
561
            $(".ClearAll").on("click", function(e) {
559
            $(".ClearAll").on("click", function (e) {
562
                e.preventDefault();
560
                e.preventDefault();
563
                $( active_tab + " input[type='checkbox']").prop('checked', false);
561
                $(active_tab + " input[type='checkbox']").prop("checked", false);
564
                activateBatchActions( active_tab );
562
                activateBatchActions(active_tab);
565
            });
563
            });
566
            $("a.ar-actions").on('click', function(e) {
564
            $("a.ar-actions").on("click", function (e) {
567
                // Hide menu option ?
565
                // Hide menu option ?
568
                if( $('#article-requests-requested-table:visible,#article-requests-pending-table:visible').length )
566
                if ($("#article-requests-requested-table:visible,#article-requests-pending-table:visible").length) $("a.ar-process-request").show();
569
                    $('a.ar-process-request').show();
567
                else $("a.ar-process-request").hide();
570
                else $('a.ar-process-request').hide();
571
568
572
                if( $('#article-requests-requested-table').is(":visible") )
569
                if ($("#article-requests-requested-table").is(":visible")) $("a.ar-set-pending-request").show();
573
                    $('a.ar-set-pending-request').show();
570
                else $("a.ar-set-pending-request").hide();
574
                else $('a.ar-set-pending-request').hide();
575
            });
571
            });
576
572
577
            $('#myModal').on("shown.bs.modal", function () {
573
            $("#myModal").on("shown.bs.modal", function () {
578
                $('#myModal textarea').focus();
574
                $("#myModal textarea").focus();
579
            });
575
            });
580
            $('#myModal').on("hidden.bs.modal", function () {
576
            $("#myModal").on("hidden.bs.modal", function () {
581
                // Set focus back to dropdown
577
                // Set focus back to dropdown
582
                var id = $('#myModal textarea').attr('ar_id');
578
                var id = $("#myModal textarea").attr("ar_id");
583
                var link = $('span#url_'+ id).parent().parent().find('td.ar-actions').find('div.dropdown a');
579
                var link = $("span#url_" + id)
584
                if( link.length > 0 ) link[0].focus();
580
                    .parent()
581
                    .parent()
582
                    .find("td.ar-actions")
583
                    .find("div.dropdown a");
584
                if (link.length > 0) link[0].focus();
585
            });
585
            });
586
586
587
            requested_datatable = $("#article-requests-requested-table").kohaTable({}, requested_table_settings);
587
            requested_datatable = $("#article-requests-requested-table").kohaTable({}, requested_table_settings);
Lines 594-805 Link Here
594
            processing_dt = processing_datatable.DataTable();
594
            processing_dt = processing_datatable.DataTable();
595
595
596
            active_datatable = requested_datatable;
596
            active_datatable = requested_datatable;
597
            activateBatchActions( active_tab );
597
            activateBatchActions(active_tab);
598
        });
598
        });
599
599
600
        function activateBatchActions( active_tab ){
600
        function activateBatchActions(active_tab) {
601
            // Check to see whether batch menu should be shown based on state of checkboxes
601
            // Check to see whether batch menu should be shown based on state of checkboxes
602
            if ( $( "input:checkbox", active_tab ).length > 0 ) {
602
            if ($("input:checkbox", active_tab).length > 0) {
603
                // There are rows with checkboxes
603
                // There are rows with checkboxes
604
                $( "[class$='_table_controls']", active_tab ).show();
604
                $("[class$='_table_controls']", active_tab).show();
605
                if ( $( "input:checkbox:checked", active_tab ).length > 0 ) {
605
                if ($("input:checkbox:checked", active_tab).length > 0) {
606
                    $( "[id^='article-menu-']", active_tab ).css("display","inline-block");
606
                    $("[id^='article-menu-']", active_tab).css("display", "inline-block");
607
                } else {
607
                } else {
608
                    $( "[id^='article-menu-']", active_tab ).hide();
608
                    $("[id^='article-menu-']", active_tab).hide();
609
                }
609
                }
610
            } else {
610
            } else {
611
                // All rows have been removed
611
                // All rows have been removed
612
                $("[class$='_table_controls']", active_tab ).hide();
612
                $("[class$='_table_controls']", active_tab).hide();
613
            }
613
            }
614
        }
614
        }
615
615
616
        function HandleMulti( fnHandler, id, a ) {
616
        function HandleMulti(fnHandler, id, a) {
617
            last_cancel_reason = undefined;
617
            last_cancel_reason = undefined;
618
            if( id !== 0 ) { fnHandler( id, a ); return; }
618
            if (id !== 0) {
619
            $( active_tab + " input[type='checkbox']:checked").each(function() {
619
                fnHandler(id, a);
620
                fnHandler( $(this).attr('reqid'), $(this).closest('tr').find('td.ar-actions div a') );
620
                return;
621
            }
622
            $(active_tab + " input[type='checkbox']:checked").each(function () {
623
                fnHandler($(this).attr("reqid"), $(this).closest("tr").find("td.ar-actions div a"));
621
            });
624
            });
622
        }
625
        }
623
626
624
        function PrintSlip(id, a) {
627
        function PrintSlip(id, a) {
625
            var link = 'article-request-slip.pl?id='+id;
628
            var link = "article-request-slip.pl?id=" + id;
626
            window.open(link, 'popup', 'width=600,height=400,resizable=1,toolbar=0,scrollbars=1,top');
629
            window.open(link, "popup", "width=600,height=400,resizable=1,toolbar=0,scrollbars=1,top");
627
        }
630
        }
628
        $(".ar-print-request").on("click", function (e){
631
        $(".ar-print-request").on("click", function (e) {
629
            e.preventDefault();
632
            e.preventDefault();
630
            HandleMulti(PrintSlip, $(this).data('ar-id'));
633
            HandleMulti(PrintSlip, $(this).data("ar-id"));
631
        });
634
        });
632
635
633
        $('#modal-cancellation-reason').on('change', function(e) {
636
        $("#modal-cancellation-reason").on("change", function (e) {
634
            let reason = $(this).val();
637
            let reason = $(this).val();
635
            $('#modal-notes').attr('disabled', !!reason);
638
            $("#modal-notes").attr("disabled", !!reason);
636
        })
639
        });
637
640
638
        // Confirm cancellation of article requests
641
        // Confirm cancellation of article requests
639
        let cancel_id;
642
        let cancel_id;
640
        let cancel_a;
643
        let cancel_a;
641
        $("#cancelModalConfirmBtn").on("click",function(e) {
644
        $("#cancelModalConfirmBtn").on("click", function (e) {
642
            let reason = $("#modal-cancellation-reason").val();
645
            let reason = $("#modal-cancellation-reason").val();
643
            let notes = $("#modal-notes").val();
646
            let notes = $("#modal-notes").val();
644
            let query = '?'+(reason?'cancellation_reason='+reason:'notes='+notes)
647
            let query = "?" + (reason ? "cancellation_reason=" + reason : "notes=" + notes);
645
648
646
            HandleMulti(function(id, a) {
649
            HandleMulti(
647
                var table_row = a.closest('tr');
650
                function (id, a) {
648
                table_row.find('.ar-process-request').remove();
651
                    var table_row = a.closest("tr");
649
                table_row.find('input[type="checkbox"]').prop('checked', false);
652
                    table_row.find(".ar-process-request").remove();
650
653
                    table_row.find('input[type="checkbox"]').prop("checked", false);
651
654
652
                a.closest('td').prepend('<img src="' + interface + '/' + theme + '/img/spinner-small.gif"/>').find('div.dropdown').hide();
655
                    a.closest("td")
653
                $.ajax({
656
                        .prepend('<img src="' + interface + "/" + theme + '/img/spinner-small.gif"/>')
654
                    type: "DELETE",
657
                        .find("div.dropdown")
655
                    url: '/api/v1/article_requests/'+id+query,
658
                        .hide();
656
                    success: function( data ) {
659
                    $.ajax({
657
                        active_datatable.DataTable().row( table_row ).remove().draw();
660
                        type: "DELETE",
658
                        UpdateTabCounts();
661
                        url: "/api/v1/article_requests/" + id + query,
659
                        activateBatchActions( active_tab );
662
                        success: function (data) {
660
                    }
663
                            active_datatable.DataTable().row(table_row).remove().draw();
661
                });
664
                            UpdateTabCounts();
662
            }, cancel_id, cancel_a)
665
                            activateBatchActions(active_tab);
666
                        },
667
                    });
668
                },
669
                cancel_id,
670
                cancel_a
671
            );
663
        });
672
        });
664
673
665
        function PrintMultipleSlip() {
674
        function PrintMultipleSlip() {
666
            var ids = [];
675
            var ids = [];
667
            $( active_tab + " input[type='checkbox']:checked").each(function() {
676
            $(active_tab + " input[type='checkbox']:checked").each(function () {
668
                ids.push($(this).attr('reqid'));
677
                ids.push($(this).attr("reqid"));
669
            });
678
            });
670
            var link = 'article-request-slip.pl?multi=1&id='+ids.join(',');
679
            var link = "article-request-slip.pl?multi=1&id=" + ids.join(",");
671
            window.open(link, 'popup', 'width=600,height=400,resizable=1,toolbar=0,scrollbars=1,top');
680
            window.open(link, "popup", "width=600,height=400,resizable=1,toolbar=0,scrollbars=1,top");
672
        }
681
        }
673
        $(".ar-print-multiple-requests").on("click", function (e){
682
        $(".ar-print-multiple-requests").on("click", function (e) {
674
            e.preventDefault();
683
            e.preventDefault();
675
            PrintMultipleSlip();
684
            PrintMultipleSlip();
676
        });
685
        });
677
686
678
        function Cancel( id, a ) {
687
        function Cancel(id, a) {
679
            cancel_id = id;
688
            cancel_id = id;
680
            cancel_a = a;
689
            cancel_a = a;
681
690
682
            $('#cancelModal').modal('show');
691
            $("#cancelModal").modal("show");
683
        }
692
        }
684
        $(".ar-cancel-request").on("click", function (e){
693
        $(".ar-cancel-request").on("click", function (e) {
685
            e.preventDefault();
694
            e.preventDefault();
686
            HandleMulti(Cancel, $(this).data('ar-id'), $(this));
695
            HandleMulti(Cancel, $(this).data("ar-id"), $(this));
687
        });
696
        });
688
697
689
        async function Process( id, a ) {
698
        async function Process(id, a) {
690
            var table_row = a.closest('tr');
699
            var table_row = a.closest("tr");
691
            var table = a.closest('table');
700
            var table = a.closest("table");
692
            var orig_dt = table.attr('id')==='article-requests-pending-table'?pending_dt:requested_dt;
701
            var orig_dt = table.attr("id") === "article-requests-pending-table" ? pending_dt : requested_dt;
693
702
694
            a.closest('td').prepend('<img src="' + interface + '/' + theme + '/img/spinner-small.gif" class="spinner"/>').find('div.dropdown').hide();
703
            a.closest("td")
704
                .prepend('<img src="' + interface + "/" + theme + '/img/spinner-small.gif" class="spinner"/>')
705
                .find("div.dropdown")
706
                .hide();
695
707
696
            const client = APIClient.article_request;
708
            const client = APIClient.article_request;
697
            await client.articleRequests.process(id).then(
709
            await client.articleRequests.process(id).then(
698
                success => {
710
                success => {
699
                    $("img.spinner").remove();
711
                    $("img.spinner").remove();
700
                    table_row.find('.ar-process-request').remove();
712
                    table_row.find(".ar-process-request").remove();
701
                    table_row.find('input[type="checkbox"]').prop('checked', false);
713
                    table_row.find('input[type="checkbox"]').prop("checked", false);
702
                    orig_dt.row( table_row ).remove().draw();
714
                    orig_dt.row(table_row).remove().draw();
703
                    processing_dt.row.add( table_row ).draw();
715
                    processing_dt.row.add(table_row).draw();
704
                    UpdateTabCounts();
716
                    UpdateTabCounts();
705
                    activateBatchActions( active_tab );
717
                    activateBatchActions(active_tab);
706
                },
718
                },
707
                error => {
719
                error => {
708
                    console.warn("Something wrong happened: %s".format(error));
720
                    console.warn("Something wrong happened: %s".format(error));
709
                }
721
                }
710
            );
722
            );
711
        }
723
        }
712
        $(".ar-process-request").on("click", function (e){
724
        $(".ar-process-request").on("click", function (e) {
713
            e.preventDefault();
725
            e.preventDefault();
714
            HandleMulti(Process, $(this).data('ar-id'), $(this));
726
            HandleMulti(Process, $(this).data("ar-id"), $(this));
715
        });
727
        });
716
728
717
        async function Complete( id, a ) {
729
        async function Complete(id, a) {
718
            // if it is a scan, check if urls field is filled
730
            // if it is a scan, check if urls field is filled
719
            var urlspan = $('span#url_'+id);
731
            var urlspan = $("span#url_" + id);
720
            if( urlspan.length>0 && urlspan.text() === '' ) {
732
            if (urlspan.length > 0 && urlspan.text() === "") {
721
                alert( _("Please fill URL before completing request.") );
733
                alert(_("Please fill URL before completing request."));
722
                return;
734
                return;
723
            }
735
            }
724
            a.closest('td').prepend('<img src="' + interface + '/' + theme + '/img/spinner-small.gif"/>').find('div.dropdown').hide();
736
            a.closest("td")
737
                .prepend('<img src="' + interface + "/" + theme + '/img/spinner-small.gif"/>')
738
                .find("div.dropdown")
739
                .hide();
725
            const client = APIClient.article_request;
740
            const client = APIClient.article_request;
726
            await client.articleRequests.complete(id).then(
741
            await client.articleRequests.complete(id).then(
727
                success => {
742
                success => {
728
                    $("img.spinner").remove();
743
                    $("img.spinner").remove();
729
                    active_datatable.DataTable().row( a.closest('tr') ).remove().draw();
744
                    active_datatable.DataTable().row(a.closest("tr")).remove().draw();
730
                    UpdateTabCounts();
745
                    UpdateTabCounts();
731
                    activateBatchActions( active_tab );
746
                    activateBatchActions(active_tab);
732
                },
747
                },
733
                error => {
748
                error => {
734
                    console.warn("Something wrong happened: %s".format(error));
749
                    console.warn("Something wrong happened: %s".format(error));
735
                }
750
                }
736
            );
751
            );
737
        }
752
        }
738
        $(".ar-complete-request").on("click", function (e){
753
        $(".ar-complete-request").on("click", function (e) {
739
            e.preventDefault();
754
            e.preventDefault();
740
            HandleMulti(Complete, $(this).data('ar-id'), $(this));
755
            HandleMulti(Complete, $(this).data("ar-id"), $(this));
741
        });
756
        });
742
757
743
        async function SetPending( id, a ) {
758
        async function SetPending(id, a) {
744
            var table_row = a.closest('tr');
759
            var table_row = a.closest("tr");
745
            table_row.find('.ar-set-pending-request').remove();
760
            table_row.find(".ar-set-pending-request").remove();
746
            table_row.find('input[type="checkbox"]').prop('checked', false);
761
            table_row.find('input[type="checkbox"]').prop("checked", false);
747
            a.closest('td').prepend('<img src="' + interface + '/' + theme + '/img/spinner-small.gif" class="spinner"/>').find('div.dropdown').hide();
762
            a.closest("td")
763
                .prepend('<img src="' + interface + "/" + theme + '/img/spinner-small.gif" class="spinner"/>')
764
                .find("div.dropdown")
765
                .hide();
748
            const client = APIClient.article_request;
766
            const client = APIClient.article_request;
749
            await client.articleRequests.pending(id).then(
767
            await client.articleRequests.pending(id).then(
750
                success => {
768
                success => {
751
                    $("img.spinner").remove();
769
                    $("img.spinner").remove();
752
                    requested_dt.row( table_row ).remove().draw();
770
                    requested_dt.row(table_row).remove().draw();
753
                    pending_dt.row.add( table_row ).draw();
771
                    pending_dt.row.add(table_row).draw();
754
                    UpdateTabCounts();
772
                    UpdateTabCounts();
755
                    activateBatchActions( active_tab );
773
                    activateBatchActions(active_tab);
756
                },
774
                },
757
                error => {
775
                error => {
758
                    console.warn("Something wrong happened: %s".format(error));
776
                    console.warn("Something wrong happened: %s".format(error));
759
                }
777
                }
760
            );
778
            );
761
        }
779
        }
762
        $(".ar-set-pending-request").on("click", function (e){
780
        $(".ar-set-pending-request").on("click", function (e) {
763
            e.preventDefault();
781
            e.preventDefault();
764
            HandleMulti(SetPending, $(this).data('ar-id'), $(this));
782
            HandleMulti(SetPending, $(this).data("ar-id"), $(this));
765
        });
783
        });
766
784
767
        function UpdateTabCounts() {
785
        function UpdateTabCounts() {
768
            $("#ar_requested_count").html( requested_dt.rows().count() );
786
            $("#ar_requested_count").html(requested_dt.rows().count());
769
            $("#ar_pending_count").html( pending_dt.rows().count() );
787
            $("#ar_pending_count").html(pending_dt.rows().count());
770
            $("#ar_processing_count").html( processing_dt.rows().count() );
788
            $("#ar_processing_count").html(processing_dt.rows().count());
771
        }
789
        }
772
790
773
        function EditURLs(id) {
791
        function EditURLs(id) {
774
            var urls = $('span#url_'+ id).text();
792
            var urls = $("span#url_" + id).text();
775
            $('#myModal textarea').val(urls);
793
            $("#myModal textarea").val(urls);
776
            $('#myModal textarea').attr('ar_id', id);
794
            $("#myModal textarea").attr("ar_id", id);
777
            $('#myModal').modal('show');
795
            $("#myModal").modal("show");
778
        }
796
        }
779
        $(".ar-edit-urls").on("click", function (e){
797
        $(".ar-edit-urls").on("click", function (e) {
780
            e.preventDefault();
798
            e.preventDefault();
781
            HandleMulti(EditURLs, $(this).data('ar-id'));
799
            HandleMulti(EditURLs, $(this).data("ar-id"));
782
        });
800
        });
783
801
784
        async function SaveURLs(newurl) {
802
        async function SaveURLs(newurl) {
785
            var id = $('#myModal textarea').attr('ar_id');
803
            var id = $("#myModal textarea").attr("ar_id");
786
            $('span#url_'+ id).text(newurl);
804
            $("span#url_" + id).text(newurl);
787
            if(newurl)
805
            if (newurl) $("span#url_yesno_" + id).text(_("Yes"));
788
                $('span#url_yesno_'+id).text(_("Yes"));
806
            else $("span#url_yesno_" + id).text(_("No"));
789
            else
790
                $('span#url_yesno_'+id).text(_("No"));
791
807
792
            const client = APIClient.article_request;
808
            const client = APIClient.article_request;
793
            await client.articleRequests.update_urls(id, newurl).then(
809
            await client.articleRequests.update_urls(id, newurl).then(
794
                success => {
810
                success => {},
795
                },
796
                error => {
811
                error => {
797
                    console.warn("Something wrong happened: %s".format(error));
812
                    console.warn("Something wrong happened: %s".format(error));
798
                }
813
                }
799
            );
814
            );
800
        }
815
        }
801
        $( '#myModal button' ).on("click", function () {
816
        $("#myModal button").on("click", function () {
802
            SaveURLs( $('#myModal textarea').val() );
817
            SaveURLs($("#myModal textarea").val());
803
        });
818
        });
804
    </script>
819
    </script>
805
[% END %]
820
[% END %]
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/curbside_pickups.tt (-101 / +101 lines)
Lines 481-492 Link Here
481
        dt_settings.push( [% TablesSettings.GetTableSettings('circ', 'curbside_pickups', 'delivered_todayt', 'json') | $raw %] );
481
        dt_settings.push( [% TablesSettings.GetTableSettings('circ', 'curbside_pickups', 'delivered_todayt', 'json') | $raw %] );
482
482
483
        const tab = "[% tab | html %]";
483
        const tab = "[% tab | html %]";
484
485
    </script>
484
    </script>
486
487
    <script>
485
    <script>
488
        let existingPickupMoments = [];
486
        let existingPickupMoments = [];
489
        pickups.forEach(function(pickup){
487
        pickups.forEach(function (pickup) {
490
            let scheduled_pickup_datetime = pickup.scheduled_pickup_datetime;
488
            let scheduled_pickup_datetime = pickup.scheduled_pickup_datetime;
491
            let pickupMoment = dayjs(scheduled_pickup_datetime);
489
            let pickupMoment = dayjs(scheduled_pickup_datetime);
492
490
Lines 494-527 Link Here
494
        });
492
        });
495
493
496
        let slots_per_day = {};
494
        let slots_per_day = {};
497
        opening_slots.forEach(function(slot){
495
        opening_slots.forEach(function (slot) {
498
            let day = slot.day;
496
            let day = slot.day;
499
            if(!slots_per_day[day]) slots_per_day[day] = [];
497
            if (!slots_per_day[day]) slots_per_day[day] = [];
500
            slots_per_day[day].push(slot);
498
            slots_per_day[day].push(slot);
501
        });
499
        });
502
500
503
        $(document).ready(function() {
501
        $(document).ready(function () {
504
502
            $("#schedule-pickup-tab").on("click", function () {
505
            $('#schedule-pickup-tab').on('click', function() {
503
                $("#find-patron").focus();
506
                $('#find-patron').focus();
507
            });
504
            });
508
505
509
            if (tab == 'schedule-pickup_panel'){
506
            if (tab == "schedule-pickup_panel") {
510
                $('#find-patron').focus();
507
                $("#find-patron").focus();
511
            }
508
            }
512
509
513
            const pickup_date = document.querySelector("#pickup_date");
510
            const pickup_date = document.querySelector("#pickup_date");
514
            if ( pickup_date ) {
511
            if (pickup_date) {
515
                const fp = pickup_date._flatpickr;
512
                const fp = pickup_date._flatpickr;
516
                fp.set('disable', [function(date) {
513
                fp.set("disable", [
517
                    return !slots_per_day.hasOwnProperty(date.getDay());
514
                    function (date) {
518
                }]);
515
                        return !slots_per_day.hasOwnProperty(date.getDay());
516
                    },
517
                ]);
519
            }
518
            }
520
519
521
            $("#pickup_date").on('change', function() {
520
            $("#pickup_date").on("change", function () {
522
521
                $("#pickup-times").empty();
523
                $('#pickup-times').empty();
522
                $("#schedule-pickup-button").prop("disabled", 1);
524
                $('#schedule-pickup-button').prop( 'disabled', 1 );
525
523
526
                var currentDate = $(this).val();
524
                var currentDate = $(this).val();
527
525
Lines 530-606 Link Here
530
                let pickupSlots = [];
528
                let pickupSlots = [];
531
                let available_count = 0;
529
                let available_count = 0;
532
                let dow = selectedDate.day(); // Sunday is 0 (at least for now)
530
                let dow = selectedDate.day(); // Sunday is 0 (at least for now)
533
                if (!slots_per_day[dow]){
531
                if (!slots_per_day[dow]) {
534
                    $('#pickup-times').html("<div>"+_("No pickup time defined for this day.")+"</div>");
532
                    $("#pickup-times").html("<div>" + _("No pickup time defined for this day.") + "</div>");
535
                    return;
533
                    return;
536
                }
534
                }
537
535
538
                slots_per_day[dow].sort((a, b) => a.start_hour - b.start_hour).forEach(function(slot){
536
                slots_per_day[dow]
539
                    let pickup_interval = policy.pickup_interval;
537
                    .sort((a, b) => a.start_hour - b.start_hour)
540
                    if (!pickup_interval) {
538
                    .forEach(function (slot) {
541
                        $('#pickup-times').html("<div>"+_("No pickup time defined for this day.")+"</div>");
539
                        let pickup_interval = policy.pickup_interval;
542
                        return;
540
                        if (!pickup_interval) {
543
                    }
541
                            $("#pickup-times").html("<div>" + _("No pickup time defined for this day.") + "</div>");
544
542
                            return;
545
                    let listStartMoment = selectedDate.hour(slot.start_hour).minute(slot.start_minute);
546
                    let listEndMoment = selectedDate.hour(slot.end_hour).minute(slot.end_minute);
547
548
                    let keep_going = true;
549
                    let now = dayjs();
550
551
                    // Initialize pickup slots starting at opening time
552
                    let pickupIntervalStartMoment = listStartMoment;
553
                    let pickupIntervalEndMoment   = listStartMoment.add(pickup_interval, 'minutes');
554
                    while (keep_going) {
555
                        let available = true;
556
                        let display_slot = true
557
558
                        if (pickupIntervalStartMoment.isBefore(now)) {
559
                            // Slots in the past are unavailable
560
                            available = false;
561
                            display_slot = false;
562
                        }
543
                        }
563
544
564
                        if (pickupIntervalEndMoment.isAfter(listEndMoment)) {
545
                        let listStartMoment = selectedDate.hour(slot.start_hour).minute(slot.start_minute);
565
                            // Slots after the end of pickup times for the day are unavailable
546
                        let listEndMoment = selectedDate.hour(slot.end_hour).minute(slot.end_minute);
566
                            available = false;
567
                        }
568
547
569
                        let pickups_scheduled = 0;
548
                        let keep_going = true;
570
                        existingPickupMoments.forEach(function(pickupMoment){
549
                        let now = dayjs();
571
                            // An existing pickup time
550
572
                            if (pickupMoment.isSameOrAfter(pickupIntervalStartMoment) && pickupMoment.isBefore(pickupIntervalEndMoment)) {
551
                        // Initialize pickup slots starting at opening time
573
                                // This calculated pickup is in use by another scheduled pickup
552
                        let pickupIntervalStartMoment = listStartMoment;
574
                                pickups_scheduled++;
553
                        let pickupIntervalEndMoment = listStartMoment.add(pickup_interval, "minutes");
554
                        while (keep_going) {
555
                            let available = true;
556
                            let display_slot = true;
557
558
                            if (pickupIntervalStartMoment.isBefore(now)) {
559
                                // Slots in the past are unavailable
560
                                available = false;
561
                                display_slot = false;
575
                            }
562
                            }
576
                        });
577
563
578
                        if (pickups_scheduled >= policy.patrons_per_interval) {
564
                            if (pickupIntervalEndMoment.isAfter(listEndMoment)) {
579
                            available = false;
565
                                // Slots after the end of pickup times for the day are unavailable
580
                        }
566
                                available = false;
567
                            }
581
568
582
                        if ( display_slot ) {
569
                            let pickups_scheduled = 0;
583
                            pickupSlots.push(
570
                            existingPickupMoments.forEach(function (pickupMoment) {
584
                                {
571
                                // An existing pickup time
585
                                    "available": available,
572
                                if (pickupMoment.isSameOrAfter(pickupIntervalStartMoment) && pickupMoment.isBefore(pickupIntervalEndMoment)) {
586
                                    "moment": pickupIntervalStartMoment,
573
                                    // This calculated pickup is in use by another scheduled pickup
587
                                    "pickups_scheduled": pickups_scheduled
574
                                    pickups_scheduled++;
588
                                }
575
                                }
589
                            );
576
                            });
590
                        }
591
577
592
                        if ( available ) {
578
                            if (pickups_scheduled >= policy.patrons_per_interval) {
593
                            available_count++;
579
                                available = false;
594
                        }
580
                            }
581
582
                            if (display_slot) {
583
                                pickupSlots.push({
584
                                    available: available,
585
                                    moment: pickupIntervalStartMoment,
586
                                    pickups_scheduled: pickups_scheduled,
587
                                });
588
                            }
589
590
                            if (available) {
591
                                available_count++;
592
                            }
595
593
596
                        pickupIntervalStartMoment = pickupIntervalEndMoment;
594
                            pickupIntervalStartMoment = pickupIntervalEndMoment;
597
                        pickupIntervalEndMoment = pickupIntervalStartMoment.add(pickup_interval, 'minutes');
595
                            pickupIntervalEndMoment = pickupIntervalStartMoment.add(pickup_interval, "minutes");
598
                        if (pickupIntervalEndMoment.isAfter(listEndMoment)) {
596
                            if (pickupIntervalEndMoment.isAfter(listEndMoment)) {
599
                            // This latest slot is after the end of pickup times for the day, so we can stop
597
                                // This latest slot is after the end of pickup times for the day, so we can stop
600
                            keep_going = false;
598
                                keep_going = false;
599
                            }
601
                        }
600
                        }
602
                    }
601
                    });
603
                });
604
602
605
                for (let i = 0; i < pickupSlots.length; i++) {
603
                for (let i = 0; i < pickupSlots.length; i++) {
606
                    let pickupSlot = pickupSlots[i];
604
                    let pickupSlot = pickupSlots[i];
Lines 611-677 Link Here
611
                    $("#pickup-times").append(`<span class="pickup_time"><input type="radio" id="slot_${i}" name="pickup_time" value="${optValue}" ${disabled} /> <label for="slot_${i}">${optText} (${pickups_scheduled})</label></span>`);
609
                    $("#pickup-times").append(`<span class="pickup_time"><input type="radio" id="slot_${i}" name="pickup_time" value="${optValue}" ${disabled} /> <label for="slot_${i}">${optText} (${pickups_scheduled})</label></span>`);
612
                }
610
                }
613
611
614
                $('#pickup-times').show();
612
                $("#pickup-times").show();
615
                $('#schedule-pickup-button').prop( 'disabled', available_count <= 0 );
613
                $("#schedule-pickup-button").prop("disabled", available_count <= 0);
616
            });
614
            });
617
615
618
            $("#create-pickup").on('submit', function(){
616
            $("#create-pickup").on("submit", function () {
619
                if ( ! $("input[type='radio']:checked").length ) {
617
                if (!$("input[type='radio']:checked").length) {
620
                    alert(_("Please select a date and a pickup time"))
618
                    alert(_("Please select a date and a pickup time"));
621
                    return false;
619
                    return false;
622
                }
620
                }
623
                return true;
621
                return true;
624
            });
622
            });
625
623
626
            if ( $("#find-patron").length ) {
624
            if ($("#find-patron").length) {
627
                patron_autocomplete($("#find-patron"), { 'on-select-callback': function( event, ui ) {
625
                patron_autocomplete($("#find-patron"), {
626
                    "on-select-callback": function (event, ui) {
628
                        window.location.href = "/cgi-bin/koha/circ/curbside_pickups.pl?op=find-patron&borrowernumber=" + ui.item.patron_id;
627
                        window.location.href = "/cgi-bin/koha/circ/curbside_pickups.pl?op=find-patron&borrowernumber=" + ui.item.patron_id;
629
                        return false;
628
                        return false;
630
                    }
629
                    },
631
                });
630
                });
632
            }
631
            }
633
632
634
            $("#pickup-tabs a[data-bs-toggle='tab']").on("shown.bs.tab", function (e) {
633
            $("#pickup-tabs a[data-bs-toggle='tab']").on("shown.bs.tab", function (e) {
635
                $("#current-tab").val($(this).attr('href').substring(1)); // Remove #
634
                $("#current-tab").val($(this).attr("href").substring(1)); // Remove #
636
            });
635
            });
637
            $("#auto_refresh,#refresh_delay").on("change", function(){
636
            $("#auto_refresh,#refresh_delay").on("change", function () {
638
                set_interval_if_needed();
637
                set_interval_if_needed();
639
            });
638
            });
640
639
641
            set_interval_if_needed();
640
            set_interval_if_needed();
642
641
643
            let dt_tables = new Array("to_be_stagedt", "staged_and_readyt", "patron_is_outsidet", "delivered_todayt");
642
            let dt_tables = new Array("to_be_stagedt", "staged_and_readyt", "patron_is_outsidet", "delivered_todayt");
644
            dt_tables.forEach(function( id, index ){
643
            dt_tables.forEach(function (id, index) {
645
                $("#" + id).kohaTable({
644
                $("#" + id).kohaTable(
646
                    autoWidth: false
645
                    {
647
                }, dt_settings[ index ] );
646
                        autoWidth: false,
647
                    },
648
                    dt_settings[index]
649
                );
648
            });
650
            });
649
650
651
        });
651
        });
652
652
653
        let refresh_interval_id = 0;
653
        let refresh_interval_id = 0;
654
        let countdown_interval_id = 0;
654
        let countdown_interval_id = 0;
655
        function set_interval(refresh_delay_ms){
655
        function set_interval(refresh_delay_ms) {
656
            clear_intervals();
656
            clear_intervals();
657
            let next_refresh = new Date();
657
            let next_refresh = new Date();
658
            next_refresh.setSeconds(next_refresh.getSeconds() + refresh_delay_ms / 1000);
658
            next_refresh.setSeconds(next_refresh.getSeconds() + refresh_delay_ms / 1000);
659
659
660
            countdown_interval_id = setInterval(function() {
660
            countdown_interval_id = setInterval(function () {
661
                const now = new Date().getTime();
661
                const now = new Date().getTime();
662
                const seconds = Math.floor(( next_refresh - now + 1 ) / 1000);
662
                const seconds = Math.floor((next_refresh - now + 1) / 1000);
663
                if ( seconds > 0 ) {
663
                if (seconds > 0) {
664
                    $("#refresh_info").text(_("Refresh in %s seconds").format(seconds));
664
                    $("#refresh_info").text(_("Refresh in %s seconds").format(seconds));
665
                } else {
665
                } else {
666
                    $("#refresh_info").text(""); // In case something is going wrong
666
                    $("#refresh_info").text(""); // In case something is going wrong
667
                }
667
                }
668
            }, 1000);
668
            }, 1000);
669
669
670
            setInterval(function() {
670
            setInterval(function () {
671
                $(".refresh-form:visible").submit();
671
                $(".refresh-form:visible").submit();
672
            }, refresh_delay_ms);
672
            }, refresh_delay_ms);
673
        }
673
        }
674
        function clear_intervals(){
674
        function clear_intervals() {
675
            if (refresh_interval_id) {
675
            if (refresh_interval_id) {
676
                clearInterval(refresh_interval_id);
676
                clearInterval(refresh_interval_id);
677
                refresh_interval_id = 0;
677
                refresh_interval_id = 0;
Lines 682-692 Link Here
682
            }
682
            }
683
        }
683
        }
684
684
685
        function set_interval_if_needed(){
685
        function set_interval_if_needed() {
686
            const refresh_delay = $("#refresh_delay").val();
686
            const refresh_delay = $("#refresh_delay").val();
687
            const auto_refresh = $("#auto_refresh").is(":checked");
687
            const auto_refresh = $("#auto_refresh").is(":checked");
688
688
689
            if (auto_refresh && refresh_delay){
689
            if (auto_refresh && refresh_delay) {
690
                set_interval(refresh_delay * 1000);
690
                set_interval(refresh_delay * 1000);
691
            } else {
691
            } else {
692
                clear_intervals();
692
                clear_intervals();
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/overdue.tt (-22 / +21 lines)
Lines 352-382 Link Here
352
            table_settings['columns'].splice(13, 1);
352
            table_settings['columns'].splice(13, 1);
353
        [% END %]
353
        [% END %]
354
    </script>
354
    </script>
355
356
    <script>
355
    <script>
357
        function clone_input( node, original_id ) {
356
        function clone_input(node, original_id) {
358
            var original = node;
357
            var original = node;
359
            var clone = original.clone();
358
            var clone = original.clone();
360
            var appendid = original_id + "-" + Math.floor(Math.random()*1000+1);
359
            var appendid = original_id + "-" + Math.floor(Math.random() * 1000 + 1);
361
            clone.find(".delete_clone").show();
360
            clone.find(".delete_clone").show();
362
            if( clone.find("select").length ){
361
            if (clone.find("select").length) {
363
                /* <select> element is present */
362
                /* <select> element is present */
364
                clone.find("select").removeClass("select2-hidden-accessible").removeAttr("data-select2-id").attr("id", appendid );
363
                clone.find("select").removeClass("select2-hidden-accessible").removeAttr("data-select2-id").attr("id", appendid);
365
                clone.find(".select2").remove();
364
                clone.find(".select2").remove();
366
                original.after( clone );
365
                original.after(clone);
367
                $("#" + appendid ).select2();
366
                $("#" + appendid).select2();
368
            } else if( clone.find(".flatpickr").length ){
367
            } else if (clone.find(".flatpickr").length) {
369
                clone.attr("id", appendid );
368
                clone.attr("id", appendid);
370
                original.after( clone );
369
                original.after(clone);
371
                apply_flatpickr(clone.find(".flatpickr"));
370
                apply_flatpickr(clone.find(".flatpickr"));
372
            } else {
371
            } else {
373
                clone.attr("id", appendid );
372
                clone.attr("id", appendid);
374
                original.after( clone );
373
                original.after(clone);
375
            }
374
            }
376
        }
375
        }
377
376
378
        function update_date_due_filters_visibility(){
377
        function update_date_due_filters_visibility() {
379
            if( $("#showall").is(":checked")) {
378
            if ($("#showall").is(":checked")) {
380
                $(".date_due_filter").hide();
379
                $(".date_due_filter").hide();
381
                $("#from").prop("disabled", true);
380
                $("#from").prop("disabled", true);
382
                $("#to").prop("disabled", true);
381
                $("#to").prop("disabled", true);
Lines 387-394 Link Here
387
            }
386
            }
388
        }
387
        }
389
388
390
        $(document).ready(function(){
389
        $(document).ready(function () {
391
           $("#overduest").kohaTable(
390
            $("#overduest").kohaTable(
392
                {
391
                {
393
                    pagingType: "full",
392
                    pagingType: "full",
394
                    autoWidth: false,
393
                    autoWidth: false,
Lines 396-419 Link Here
396
                table_settings
395
                table_settings
397
            );
396
            );
398
397
399
            $("#showall").on("change", function(){
398
            $("#showall").on("change", function () {
400
                update_date_due_filters_visibility();
399
                update_date_due_filters_visibility();
401
            });
400
            });
402
            update_date_due_filters_visibility();
401
            update_date_due_filters_visibility();
403
402
404
            $(".pattrodue-input").each(function(){
403
            $(".pattrodue-input").each(function () {
405
                $(this).select2();
404
                $(this).select2();
406
            });
405
            });
407
406
408
            $("body").on("click", ".delete_clone", function(e){
407
            $("body").on("click", ".delete_clone", function (e) {
409
                e.preventDefault();
408
                e.preventDefault();
410
                $(this).parent().remove();
409
                $(this).parent().remove();
411
            });
410
            });
412
411
413
            $("body").on("click", ".clone-attribute", function(e){
412
            $("body").on("click", ".clone-attribute", function (e) {
414
                e.preventDefault();
413
                e.preventDefault();
415
                clone_input( $(this).parent(), $(this).data("original-id") );
414
                clone_input($(this).parent(), $(this).data("original-id"));
416
            })
415
            });
417
        });
416
        });
418
    </script>
417
    </script>
419
[% END %]
418
[% END %]
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/pendingbookings.tt (-146 / +146 lines)
Lines 118-285 Link Here
118
    <script>
118
    <script>
119
        let table_settings = [% TablesSettings.GetTableSettings( 'circ', 'bookings', 'bookings-to-collect', 'json' ) | $raw %];
119
        let table_settings = [% TablesSettings.GetTableSettings( 'circ', 'bookings', 'bookings-to-collect', 'json' ) | $raw %];
120
120
121
            let all_libraries  = [% To.json(Branches.all) | $raw %].map(e => {
121
        let all_libraries  = [% To.json(Branches.all) | $raw %].map(e => {
122
                e['_id'] = e.branchcode;
122
            e['_id'] = e.branchcode;
123
                e['_str'] = e.branchname;
123
            e['_str'] = e.branchname;
124
                return e;
124
            return e;
125
            });
125
        });
126
    </script>
126
    </script>
127
128
    <script>
127
    <script>
129
            var coded_values = {
128
        var coded_values = {
130
                library: new Map(all_libraries.map( l => [l.branchname, l.branchcode] )),
129
            library: new Map(all_libraries.map(l => [l.branchname, l.branchcode])),
131
            };
130
        };
132
133
            let filters_options = {
134
                libraries: all_libraries,
135
            };
136
        $(document).ready(function() {
137
131
132
        let filters_options = {
133
            libraries: all_libraries,
134
        };
135
        $(document).ready(function () {
138
            let additional_filters = {
136
            let additional_filters = {
139
                start_date: function() {
137
                start_date: function () {
140
                   let fromdate = $("#from");
138
                    let fromdate = $("#from");
141
                   let isoFrom;
139
                    let isoFrom;
142
                   if ( fromdate.val() !== '' ) {
140
                    if (fromdate.val() !== "") {
143
                     let selectedDate = fromdate.get(0)._flatpickr.selectedDates[0];
141
                        let selectedDate = fromdate.get(0)._flatpickr.selectedDates[0];
144
                     selectedDate.setHours(0, 0, 0, 0);
142
                        selectedDate.setHours(0, 0, 0, 0);
145
                     isoFrom = selectedDate.toISOString();
143
                        isoFrom = selectedDate.toISOString();
146
                   }
144
                    }
147
145
148
                   let todate = $("#to");
146
                    let todate = $("#to");
149
                   let isoTo;
147
                    let isoTo;
150
                   if ( todate.val() !== '' ) {
148
                    if (todate.val() !== "") {
151
                     let selectedDate = todate.get(0)._flatpickr.selectedDates[0];
149
                        let selectedDate = todate.get(0)._flatpickr.selectedDates[0];
152
                     selectedDate.setHours(23, 59, 59, 999);
150
                        selectedDate.setHours(23, 59, 59, 999);
153
                     isoTo = selectedDate.toISOString();
151
                        isoTo = selectedDate.toISOString();
154
                   }
152
                    }
155
153
156
                   if ( isoFrom || isoTo ) {
154
                    if (isoFrom || isoTo) {
157
                     return { '>=': isoFrom, '<=': isoTo };
155
                        return { ">=": isoFrom, "<=": isoTo };
158
                   } else {
156
                    } else {
159
                     return
157
                        return;
160
                   }
158
                    }
161
                },
159
                },
162
                'item.holding_library_id': function() {
160
                "item.holding_library_id": function () {
163
                   let library = $("#holding_library").find(":selected").val();
161
                    let library = $("#holding_library").find(":selected").val();
164
                   return library;
162
                    return library;
165
                },
163
                },
166
                'pickup_library_id': function() {
164
                pickup_library_id: function () {
167
                    let library = $("#pickup_library").find(":selected").val();
165
                    let library = $("#pickup_library").find(":selected").val();
168
                    return library;
166
                    return library;
169
                }
167
                },
170
            };
168
            };
171
169
172
            var bookings_table_url = '/api/v1/bookings?';
170
            var bookings_table_url = "/api/v1/bookings?";
173
            var bookings_table = $("#bookingst").kohaTable({
171
            var bookings_table = $("#bookingst").kohaTable(
174
                ajax: {
175
                    url: bookings_table_url
176
                },
177
                embed: [
178
                    "biblio",
179
                    "item+strings",
180
                    "item.checkout",
181
                    "patron",
182
                    "pickup_library"
183
                ],
184
                order: [[ 7, "asc" ]],
185
                columns: [{
186
                    data: "booking_id",
187
                    title: _("Booking ID"),
188
                    visible: false
189
                },
190
                {
172
                {
191
                    data: "me.pickup_library_id",
173
                    ajax: {
192
                    title: _("Pickup library"),
174
                        url: bookings_table_url,
193
                    datatype: "coded_value:library",
175
                    },
194
                    dataFilter: "libraries",
176
                    embed: ["biblio", "item+strings", "item.checkout", "patron", "pickup_library"],
195
                    searchable: true,
177
                    order: [[7, "asc"]],
196
                    orderable: true,
178
                    columns: [
197
                    render: function( data, type, row, meta ) {
179
                        {
198
                        return escape_str(row.pickup_library_id ? row.pickup_library.name : row.pickup_library_id);
180
                            data: "booking_id",
199
                    }
181
                            title: _("Booking ID"),
182
                            visible: false,
183
                        },
184
                        {
185
                            data: "me.pickup_library_id",
186
                            title: _("Pickup library"),
187
                            datatype: "coded_value:library",
188
                            dataFilter: "libraries",
189
                            searchable: true,
190
                            orderable: true,
191
                            render: function (data, type, row, meta) {
192
                                return escape_str(row.pickup_library_id ? row.pickup_library.name : row.pickup_library_id);
193
                            },
194
                        },
195
                        {
196
                            data: "biblio.title",
197
                            title: _("Title"),
198
                            searchable: true,
199
                            orderable: true,
200
                            render: function (data, type, row, meta) {
201
                                return $biblio_to_html(row.biblio, {
202
                                    link: "bookings",
203
                                });
204
                            },
205
                        },
206
                        {
207
                            data: "item.external_id",
208
                            title: _("Item"),
209
                            searchable: true,
210
                            orderable: true,
211
                            defaultContent: _("Any item"),
212
                            render: function (data, type, row, meta) {
213
                                if (row.item) {
214
                                    return row.item.external_id + " (" + row.booking_id + ")";
215
                                } else {
216
                                    return null;
217
                                }
218
                            },
219
                        },
220
                        {
221
                            data: "item.callnumber",
222
                            title: _("Callnumber"),
223
                            searchable: true,
224
                            orderable: true,
225
                            render: function (data, type, row, meta) {
226
                                if (row.item) {
227
                                    return row.item.callnumber;
228
                                } else {
229
                                    return null;
230
                                }
231
                            },
232
                        },
233
                        {
234
                            data: "item.location",
235
                            title: _("Location"),
236
                            searchable: false,
237
                            orderable: false,
238
                            render: function (data, type, row, meta) {
239
                                if (row.item) {
240
                                    if (row.item.checked_out_date) {
241
                                        return _("On loan, due: ") + $date(row.item.checked_out_date);
242
                                    } else {
243
                                        return row.item._strings.location.str;
244
                                    }
245
                                } else {
246
                                    return null;
247
                                }
248
                            },
249
                        },
250
                        {
251
                            data: "patron.firstname:patron.surname",
252
                            title: _("Patron"),
253
                            searchable: true,
254
                            orderable: true,
255
                            render: function (data, type, row, meta) {
256
                                return $patron_to_html(row.patron, {
257
                                    display_cardnumber: true,
258
                                    url: true,
259
                                });
260
                            },
261
                        },
262
                        {
263
                            data: "start_date",
264
                            name: "start_date",
265
                            title: _("Booking dates"),
266
                            type: "date",
267
                            searchable: false,
268
                            orderable: true,
269
                            render: function (data, type, row, meta) {
270
                                return $date(row.start_date) + " - " + $date(row.end_date);
271
                            },
272
                        },
273
                    ],
200
                },
274
                },
201
                {
275
                table_settings,
202
                    data: "biblio.title",
276
                1,
203
                    title: _("Title"),
277
                additional_filters,
204
                    searchable: true,
278
                filters_options
205
                    orderable: true,
279
            );
206
                    render: function(data,type,row,meta) {
207
                        return $biblio_to_html(row.biblio, {
208
                            link: 'bookings'
209
                        });
210
                    }
211
                },
212
                {
213
                    data: "item.external_id",
214
                    title: _("Item"),
215
                    searchable: true,
216
                    orderable: true,
217
                    defaultContent: _("Any item"),
218
                    render: function(data,type,row,meta) {
219
                        if ( row.item ) {
220
                            return row.item.external_id + " (" + row.booking_id + ")";
221
                        } else {
222
                            return null;
223
                        }
224
                    }
225
                },
226
                {
227
                    data: "item.callnumber",
228
                    title: _("Callnumber"),
229
                    searchable: true,
230
                    orderable: true,
231
                    render: function(data,type,row,meta) {
232
                        if ( row.item ) {
233
                            return row.item.callnumber;
234
                        } else {
235
                            return null;
236
                        }
237
                    }
238
                },
239
                {
240
                    data: "item.location",
241
                    title: _("Location"),
242
                    searchable: false,
243
                    orderable: false,
244
                    render: function(data,type,row,meta) {
245
                        if ( row.item ) {
246
                            if ( row.item.checked_out_date ) {
247
                                return _("On loan, due: ") + $date(row.item.checked_out_date);
248
                            } else {
249
                                return row.item._strings.location.str;
250
                            }
251
                        } else {
252
                                return null;
253
                        }
254
                    }
255
                },
256
                {
257
                    data: "patron.firstname:patron.surname",
258
                    title: _("Patron"),
259
                    searchable: true,
260
                    orderable: true,
261
                    render: function(data, type, row, meta) {
262
                        return $patron_to_html(row.patron, {
263
                            display_cardnumber: true,
264
                            url: true
265
                        });
266
                    }
267
                },
268
                {
269
                    data: "start_date",
270
                    name: "start_date",
271
                    title: _("Booking dates"),
272
                    type: "date",
273
                    searchable: false,
274
                    orderable: true,
275
                    render: function(data, type, row, meta) {
276
                        return $date(row.start_date) + ' - ' + $date(row.end_date);
277
                    }
278
                }]
279
            }, table_settings, 1, additional_filters, filters_options);
280
280
281
            /** Date filtering */
281
            /** Date filtering */
282
            $("#bookingsf").on("submit", function(e){
282
            $("#bookingsf").on("submit", function (e) {
283
                /* stop form from submitting normally */
283
                /* stop form from submitting normally */
284
                e.preventDefault();
284
                e.preventDefault();
285
                bookings_table.DataTable().draw();
285
                bookings_table.DataTable().draw();
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/pendingreserves.tt (-35 / +44 lines)
Lines 301-352 Link Here
301
    <script>
301
    <script>
302
        var table_settings = [% TablesSettings.GetTableSettings('circ', 'holds', 'holds-to-pull', 'json') | $raw %];
302
        var table_settings = [% TablesSettings.GetTableSettings('circ', 'holds', 'holds-to-pull', 'json') | $raw %];
303
    </script>
303
    </script>
304
305
    <script>
304
    <script>
306
        function get_options(column){
305
        function get_options(column) {
307
            let regex = /(<([^>]+)>)/ig; // Remove html tags
306
            let regex = /(<([^>]+)>)/gi; // Remove html tags
308
            let options = [... new Set(column
307
            let options = [
309
                .data()
308
                ...new Set(
310
                .toArray()
309
                    column
311
                .map(d => d.replace(regex, '').trim().split(/\n/gi).map(s => s.trim()).flat())
310
                        .data()
312
                .flat()
311
                        .toArray()
313
                .sort())];
312
                        .map(d =>
313
                            d
314
                                .replace(regex, "")
315
                                .trim()
316
                                .split(/\n/gi)
317
                                .map(s => s.trim())
318
                                .flat()
319
                        )
320
                        .flat()
321
                        .sort()
322
                ),
323
            ];
314
324
315
            return options
325
            return options.map(e => {
316
                .map(e => {
326
                return { _id: e, _str: e };
317
                    return {_id: e, _str: e}
327
            });
318
                });
319
        }
328
        }
320
329
321
        $(document).ready(function() {
330
        $(document).ready(function () {
322
            let filters_options = {
331
            let filters_options = {
323
                libraries: (table_dt) => get_options(table_dt.column(5)),
332
                libraries: table_dt => get_options(table_dt.column(5)),
324
                item_types: (table_dt) => get_options(table_dt.column(10)),
333
                item_types: table_dt => get_options(table_dt.column(10)),
325
                locations: (table_dt) => get_options(table_dt.column(11)),
334
                locations: table_dt => get_options(table_dt.column(11)),
326
                pickup_locations : (table_dt) => get_options(table_dt.column(15)),
335
                pickup_locations: table_dt => get_options(table_dt.column(15)),
327
            };
336
            };
328
337
329
            var holdst = $("#holdst").kohaTable(
338
            var holdst = $("#holdst").kohaTable(
330
                {
339
                {
331
                    pagingType: "full_numbers",
340
                    pagingType: "full_numbers",
332
                    columns: [
341
                    columns: [
333
                        {name: "pull_items" },
342
                        { name: "pull_items" },
334
                        {name: "available_items" },
343
                        { name: "available_items" },
335
                        {name: "patrons" },
344
                        { name: "patrons" },
336
                        {name: "patron" },
345
                        { name: "patron" },
337
                        {name: "title" },
346
                        { name: "title" },
338
                        {name: "libraries", dataFilter: "libraries" },
347
                        { name: "libraries", dataFilter: "libraries" },
339
                        {name: "barcodes" },
348
                        { name: "barcodes" },
340
                        {name: "call_numbers" },
349
                        { name: "call_numbers" },
341
                        {name: "copy_numbers" },
350
                        { name: "copy_numbers" },
342
                        {name: "enumeration" },
351
                        { name: "enumeration" },
343
                        {name: "itemtypes", dataFilter: "item_types" },
352
                        { name: "itemtypes", dataFilter: "item_types" },
344
                        {name: "locations", dataFilter: "locations" },
353
                        { name: "locations", dataFilter: "locations" },
345
                        {name: "collection" },
354
                        { name: "collection" },
346
                        {name: "hold_date" },
355
                        { name: "hold_date" },
347
                        {name: "reserve_nodes" },
356
                        { name: "reserve_nodes" },
348
                        {name: "pickup_location", dataFilter: "pickup_locations" },
357
                        { name: "pickup_location", dataFilter: "pickup_locations" },
349
                        {name: "action" },
358
                        { name: "action" },
350
                    ],
359
                    ],
351
                },
360
                },
352
                table_settings,
361
                table_settings,
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/reserveratios.tt (-16 / +13 lines)
Lines 217-239 Link Here
217
    <script>
217
    <script>
218
        var table_settings = [% TablesSettings.GetTableSettings( 'circ', 'holdsratios', 'holds-ratios', 'json' ) | $raw %];
218
        var table_settings = [% TablesSettings.GetTableSettings( 'circ', 'holdsratios', 'holds-ratios', 'json' ) | $raw %];
219
    </script>
219
    </script>
220
221
    <script>
220
    <script>
222
         $(document).ready(function() {
221
        $(document).ready(function () {
223
             $("#holds-ratios").kohaTable(
222
            $("#holds-ratios").kohaTable(
224
                 {
223
                {
225
                     order: [
224
                    order: [
226
                         [2, "desc"],
225
                        [2, "desc"],
227
                         [3, "asc"],
226
                        [3, "asc"],
228
                     ],
227
                    ],
229
                     columnDefs: [
228
                    columnDefs: [{ type: "natural", targets: ["natural"] }],
230
                         { type: "natural", targets: ["natural"] },
229
                    pagingType: "full",
231
                     ],
230
                    autoWidth: false,
232
                     pagingType: "full",
231
                },
233
                     autoWidth: false,
232
                table_settings
234
                 },
233
            );
235
                 table_settings
236
             );
237
        });
234
        });
238
    </script>
235
    </script>
239
[% END %]
236
[% END %]
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/returns.tt (-84 / +87 lines)
Lines 1522-1575 Link Here
1522
            AutomaticConfirmTransfer: [% Koha.Preference('AutomaticConfirmTransfer') ? 1 : 0 | html %],
1522
            AutomaticConfirmTransfer: [% Koha.Preference('AutomaticConfirmTransfer') ? 1 : 0 | html %],
1523
        });
1523
        });
1524
    </script>
1524
    </script>
1525
1526
    [% IF ( ReturnClaims ) %]
1525
    [% IF ( ReturnClaims ) %]
1527
        [% Asset.js("js/resolve_claim_modal.js") | $raw %]
1526
        [% Asset.js("js/resolve_claim_modal.js") | $raw %]
1528
    [% END %]
1527
    [% END %]
1529
    [% IF ( Koha.Preference('CatalogConcerns') ) %]
1528
    [% IF ( Koha.Preference('CatalogConcerns') ) %]
1530
        [% Asset.js("js/modals/add_catalog_concern.js") | $raw %]
1529
        [% Asset.js("js/modals/add_catalog_concern.js") | $raw %]
1531
    [% END %]
1530
    [% END %]
1532
1533
    <script>
1531
    <script>
1534
        function Dopop(link) {
1532
        function Dopop(link) {
1535
            var newin = window.open(link, 'popup', 'width=600,height=400,resizable=1,toolbar=0,scrollbars=1,top');
1533
            var newin = window.open(link, "popup", "width=600,height=400,resizable=1,toolbar=0,scrollbars=1,top");
1536
            $("#barcode").focus();
1534
            $("#barcode").focus();
1537
        }
1535
        }
1538
        $(document).ready(function () {
1536
        $(document).ready(function () {
1539
            $("#checkin-form").preventDoubleFormSubmit();
1537
            $("#checkin-form").preventDoubleFormSubmit();
1540
1538
1541
            $(".modal.block")
1539
            $(".modal.block")
1542
            .on('shown.bs.modal', function() {
1540
                .on("shown.bs.modal", function () {
1543
                $("#barcode").prop("disabled", true);
1541
                    $("#barcode").prop("disabled", true);
1544
                $(".show_checkin_dialog").show();
1542
                    $(".show_checkin_dialog").show();
1545
            }).on('hidden.bs.modal', function() {
1543
                })
1546
                $("#barcode").prop("disabled", false).focus();
1544
                .on("hidden.bs.modal", function () {
1547
            })
1545
                    $("#barcode").prop("disabled", false).focus();
1548
            .modal("show");
1546
                })
1549
1547
                .modal("show");
1550
            $(".modal.noblock").modal('show')
1548
1551
            .on('shown.bs.modal', function() {
1549
            $(".modal.noblock")
1552
                $("#barcode").prop("disabled", false).focus();
1550
                .modal("show")
1553
            }).on('hidden.bs.modal', function() {
1551
                .on("shown.bs.modal", function () {
1554
                $("#barcode").prop("disabled", false).focus();
1552
                    $("#barcode").prop("disabled", false).focus();
1555
            });
1553
                })
1554
                .on("hidden.bs.modal", function () {
1555
                    $("#barcode").prop("disabled", false).focus();
1556
                });
1556
1557
1557
            $("body").on("click", ".show_checkin_dialog button", function(e){
1558
            $("body").on("click", ".show_checkin_dialog button", function (e) {
1558
                e.preventDefault();
1559
                e.preventDefault();
1559
                $(".modal.audio-alert-action").modal("show");
1560
                $(".modal.audio-alert-action").modal("show");
1560
            });
1561
            });
1561
            if (reserve_id){
1562
            if (reserve_id) {
1562
                $(".print-slip").on('click', function(e) {
1563
                $(".print-slip").on("click", function (e) {
1563
                    e.preventDefault();
1564
                    e.preventDefault();
1564
                    Dopop("hold-transfer-slip.pl?reserve_id=" + reserve_id );
1565
                    Dopop("hold-transfer-slip.pl?reserve_id=" + reserve_id);
1565
                });
1566
                });
1566
                if (print_slip){
1567
                if (print_slip) {
1567
                    Dopop("hold-transfer-slip.pl?reserve_id=" + reserve_id );
1568
                    Dopop("hold-transfer-slip.pl?reserve_id=" + reserve_id);
1568
                }
1569
                }
1569
            }
1570
            }
1570
1571
1571
            if (recall_slip){
1572
            if (recall_slip) {
1572
                Dopop('/cgi-bin/koha/recalls/recall_pickup_slip.pl?recall_id=' + recall_id);
1573
                Dopop("/cgi-bin/koha/recalls/recall_pickup_slip.pl?recall_id=" + recall_id);
1573
            }
1574
            }
1574
1575
1575
            var returns_table = $("#checkedintable").kohaTable(
1576
            var returns_table = $("#checkedintable").kohaTable(
Lines 1599-1610 Link Here
1599
                    $("#barcode").addClass("input-warning");
1600
                    $("#barcode").addClass("input-warning");
1600
                    $("#dropboxmode").show();
1601
                    $("#dropboxmode").show();
1601
1602
1602
                    $("#return_date_override_fields :input").prop('disabled', true);
1603
                    $("#return_date_override_fields :input").prop("disabled", true);
1603
                } else {
1604
                } else {
1604
                    $("#barcode").removeClass("input-warning");
1605
                    $("#barcode").removeClass("input-warning");
1605
                    $("#dropboxmode").hide();
1606
                    $("#dropboxmode").hide();
1606
1607
1607
                    $("#return_date_override_fields :input").prop('disabled', false);
1608
                    $("#return_date_override_fields :input").prop("disabled", false);
1608
                }
1609
                }
1609
                $("#barcode").focus();
1610
                $("#barcode").focus();
1610
            });
1611
            });
Lines 1620-1628 Link Here
1620
                $("#barcode").focus();
1621
                $("#barcode").focus();
1621
            });
1622
            });
1622
1623
1623
            if (overduecharges){
1624
            if (overduecharges) {
1624
                $("#barcode").focus(function () {
1625
                $("#barcode").focus(function () {
1625
                    if (($("#exemptcheck").prop("checked") == true) || ($("#dropboxcheck").prop("checked") == true)) {
1626
                    if ($("#exemptcheck").prop("checked") == true || $("#dropboxcheck").prop("checked") == true) {
1626
                        $("#barcode").addClass("input-warning");
1627
                        $("#barcode").addClass("input-warning");
1627
                    } else {
1628
                    } else {
1628
                        $("#barcode").removeClass("input-warning");
1629
                        $("#barcode").removeClass("input-warning");
Lines 1633-1676 Link Here
1633
                });
1634
                });
1634
            }
1635
            }
1635
1636
1636
            $('.openWin').on("click",function(e){
1637
            $(".openWin").on("click", function (e) {
1637
                Dopop( $(this).data("url") );
1638
                Dopop($(this).data("url"));
1638
            });
1639
            });
1639
1640
1640
            $('.submit').on("click",function(e){
1641
            $(".submit").on("click", function (e) {
1641
                this.form.submit();
1642
                this.form.submit();
1642
            });
1643
            });
1643
1644
1644
            $('.cancel').on("click",function(e){
1645
            $(".cancel").on("click", function (e) {
1645
                var docancel = $("<input>").attr("type", "hidden").attr("name", "canceltransfer").val(1);
1646
                var docancel = $("<input>").attr("type", "hidden").attr("name", "canceltransfer").val(1);
1646
                $('#wrongtransferform').append(docancel);
1647
                $("#wrongtransferform").append(docancel);
1647
                this.form.submit();
1648
                this.form.submit();
1648
            });
1649
            });
1649
1650
1650
            $(".print").on("click",function(e){
1651
            $(".print").on("click", function (e) {
1651
                this.form.print_slip.value = 1;
1652
                this.form.print_slip.value = 1;
1652
                let barcode = document.getElementById('confirm-hold-barcode');
1653
                let barcode = document.getElementById("confirm-hold-barcode");
1653
                if ( barcode ) barcode.remove();
1654
                if (barcode) barcode.remove();
1654
                this.form.submit();
1655
                this.form.submit();
1655
            });
1656
            });
1656
1657
1657
            $('.print-recall').on("click",function(e){
1658
            $(".print-recall").on("click", function (e) {
1658
                this.form.recall_slip.value = 1;
1659
                this.form.recall_slip.value = 1;
1659
                this.form.submit();
1660
                this.form.submit();
1660
            });
1661
            });
1661
1662
1662
            $(".approve").on("click",function(e){
1663
            $(".approve").on("click", function (e) {
1663
                let barcode = document.getElementById('confirm-hold-barcode');
1664
                let barcode = document.getElementById("confirm-hold-barcode");
1664
                if ( barcode ) barcode.remove();
1665
                if (barcode) barcode.remove();
1665
                this.form.submit();
1666
                this.form.submit();
1666
            });
1667
            });
1667
            $(".ignore").on("click",function(e){
1668
            $(".ignore").on("click", function (e) {
1668
                e.preventDefault();
1669
                e.preventDefault();
1669
            });
1670
            });
1670
            $('.cancel-hold').on("click",function(e){
1671
            $(".cancel-hold").on("click", function (e) {
1671
                let cancel_form = document.getElementById('cancellation-reason');
1672
                let cancel_form = document.getElementById("cancellation-reason");
1672
                let cancel_reason = '';
1673
                let cancel_reason = "";
1673
                if ( cancel_form ) {
1674
                if (cancel_form) {
1674
                    cancel_reason = cancel_form.value;
1675
                    cancel_reason = cancel_form.value;
1675
                }
1676
                }
1676
                this.form.cancel_reserve.value = 1;
1677
                this.form.cancel_reserve.value = 1;
Lines 1678-1698 Link Here
1678
                this.form.submit();
1679
                this.form.submit();
1679
            });
1680
            });
1680
1681
1681
            $('.action').on("click",function(e){
1682
            $(".action").on("click", function (e) {
1682
                this.checked = false;
1683
                this.checked = false;
1683
                this.form.return_date_override.value = '';
1684
                this.form.return_date_override.value = "";
1684
                this.form.return_date_override_remember.checked = false;
1685
                this.form.return_date_override_remember.checked = false;
1685
                this.form.barcode.focus();
1686
                this.form.barcode.focus();
1686
                $("#return_date_remember").hide();
1687
                $("#return_date_remember").hide();
1687
                return false;
1688
                return false;
1688
            });
1689
            });
1689
1690
1690
            $("#return_date_override_remember").on("change", function(){
1691
            $("#return_date_override_remember").on("change", function () {
1691
                if( $(this).prop("checked" ) ){
1692
                if ($(this).prop("checked")) {
1692
                    if( $("#return_date_override").val() == "" ){
1693
                    if ($("#return_date_override").val() == "") {
1693
                        $("#saved_return_date").text( _("No date selected") );
1694
                        $("#saved_return_date").text(_("No date selected"));
1694
                    } else {
1695
                    } else {
1695
                        $("#saved_return_date").text( $("#return_date_override").val() );
1696
                        $("#saved_return_date").text($("#return_date_override").val());
1696
                    }
1697
                    }
1697
                    $("#return_date_remember").show();
1698
                    $("#return_date_remember").show();
1698
                } else {
1699
                } else {
Lines 1700-1759 Link Here
1700
                }
1701
                }
1701
            });
1702
            });
1702
1703
1703
            $(".printcheckinslip").on("click", function(e){
1704
            $(".printcheckinslip").on("click", function (e) {
1704
                e.preventDefault();
1705
                e.preventDefault();
1705
                var borrowernumber = $(this).data('borrowernumber');
1706
                var borrowernumber = $(this).data("borrowernumber");
1706
                window.open("/cgi-bin/koha/members/printslip.pl?borrowernumber=" + borrowernumber + "&amp;print=checkinslip", "printwindow");
1707
                window.open("/cgi-bin/koha/members/printslip.pl?borrowernumber=" + borrowernumber + "&amp;print=checkinslip", "printwindow");
1707
            });
1708
            });
1708
1709
1709
            // item bundles
1710
            // item bundles
1710
            $('#verify-items-bundle-contents-barcodes').on('input', function (ev) {
1711
            $("#verify-items-bundle-contents-barcodes").on("input", function (ev) {
1711
                let char = ev.target.value.slice(-1);
1712
                let char = ev.target.value.slice(-1);
1712
                if ( char.match(/\n/) ) {
1713
                if (char.match(/\n/)) {
1713
                    const barcodes = ev.target.value.split('\n').map(function(s) { return s.trim().toUpperCase() });
1714
                    const barcodes = ev.target.value.split("\n").map(function (s) {
1715
                        return s.trim().toUpperCase();
1716
                    });
1714
                    const expected = [];
1717
                    const expected = [];
1715
                    let found = 0;
1718
                    let found = 0;
1716
                    $('#items-bundle-contents-table tbody > tr').each(function () {
1719
                    $("#items-bundle-contents-table tbody > tr").each(function () {
1717
                        const barcode = this.getAttribute('data-barcode').toUpperCase();
1720
                        const barcode = this.getAttribute("data-barcode").toUpperCase();
1718
                        expected.push(barcode);
1721
                        expected.push(barcode);
1719
                        if (barcodes.includes(barcode)) {
1722
                        if (barcodes.includes(barcode)) {
1720
                            this.classList.add('ok');
1723
                            this.classList.add("ok");
1721
                            found++;
1724
                            found++;
1722
                        } else {
1725
                        } else {
1723
                            this.classList.remove('ok');
1726
                            this.classList.remove("ok");
1724
                        }
1727
                        }
1725
                    });
1728
                    });
1726
                    const last = barcodes[barcodes.length -2];
1729
                    const last = barcodes[barcodes.length - 2];
1727
                    const feedback = $('#bundle-feedback');
1730
                    const feedback = $("#bundle-feedback");
1728
                    let string;
1731
                    let string;
1729
                    if ( !expected.includes(last) ) {
1732
                    if (!expected.includes(last)) {
1730
                        feedback.fadeOut(100, function(){
1733
                        feedback.fadeOut(100, function () {
1731
                            string = _("Unexpected: ") +last;
1734
                            string = _("Unexpected: ") + last;
1732
                            feedback.addClass('alert-danger').removeClass('alert-success').html(string).fadeIn(100);
1735
                            feedback.addClass("alert-danger").removeClass("alert-success").html(string).fadeIn(100);
1733
                        });
1736
                        });
1734
                    } else {
1737
                    } else {
1735
                        feedback.fadeOut(100, function(){
1738
                        feedback.fadeOut(100, function () {
1736
                            string = _("Verified: ")+last;
1739
                            string = _("Verified: ") + last;
1737
                            feedback.addClass('alert-success').removeClass('alert-danger').html(string).fadeIn(100);
1740
                            feedback.addClass("alert-success").removeClass("alert-danger").html(string).fadeIn(100);
1738
                        });
1741
                        });
1739
                    }
1742
                    }
1740
                    $('#verify-progress').show();
1743
                    $("#verify-progress").show();
1741
                    $('#verified').text(found);
1744
                    $("#verified").text(found);
1742
                    $('#expected').text(expected.length);
1745
                    $("#expected").text(expected.length);
1743
                }
1746
                }
1744
            });
1747
            });
1745
1748
1746
            $('.bundle_remove').on('click', function() {
1749
            $(".bundle_remove").on("click", function () {
1747
                var component_itemnumber = $(this).data('itemnumber');
1750
                var component_itemnumber = $(this).data("itemnumber");
1748
                var host_itemnumber = $(this).data('hostnumber');
1751
                var host_itemnumber = $(this).data("hostnumber");
1749
                var alert = $(this).closest('div');
1752
                var alert = $(this).closest("div");
1750
                var unlink_item_url = "/api/v1/items/" + host_itemnumber + "/bundled_items/item/" + component_itemnumber;
1753
                var unlink_item_url = "/api/v1/items/" + host_itemnumber + "/bundled_items/item/" + component_itemnumber;
1751
                $.ajax({
1754
                $.ajax({
1752
                    type: "DELETE",
1755
                    type: "DELETE",
1753
                    url: unlink_item_url,
1756
                    url: unlink_item_url,
1754
                    success: function(){
1757
                    success: function () {
1755
                        alert.remove();
1758
                        alert.remove();
1756
                    }
1759
                    },
1757
                });
1760
                });
1758
            });
1761
            });
1759
1762
Lines 1767-1778 Link Here
1767
                ],
1770
                ],
1768
            });
1771
            });
1769
1772
1770
            if( !prefs.TransfersBlockCirc && prefs.AutomaticConfirmTransfer ){
1773
            if (!prefs.TransfersBlockCirc && prefs.AutomaticConfirmTransfer) {
1771
                $("#wrong-transfer-modal").on('hidden.bs.modal',function(){
1774
                $("#wrong-transfer-modal").on("hidden.bs.modal", function () {
1772
                    $("#wrongtransferform").submit();
1775
                    $("#wrongtransferform").submit();
1773
                });
1776
                });
1774
                if (was_transferred){
1777
                if (was_transferred) {
1775
                    $("#item-transfer-modal").on('hidden.bs.modal',function(){
1778
                    $("#item-transfer-modal").on("hidden.bs.modal", function () {
1776
                        $("#mainform").submit();
1779
                        $("#mainform").submit();
1777
                    });
1780
                    });
1778
                }
1781
                }
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/transfers_to_send.tt (-2 / +1 lines)
Lines 102-110 Link Here
102
            library_ids.push("[% library.branchcode | html %]");
102
            library_ids.push("[% library.branchcode | html %]");
103
        [% END %]
103
        [% END %]
104
    </script>
104
    </script>
105
106
    <script>
105
    <script>
107
        $(document).ready(function() {
106
        $(document).ready(function () {
108
            library_ids.forEach(library_id => {
107
            library_ids.forEach(library_id => {
109
                $(`#transferst${library_id}`).kohaTable({
108
                $(`#transferst${library_id}`).kohaTable({
110
                    dom: "t",
109
                    dom: "t",
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/transferstoreceive.tt (-1 lines)
Lines 119-125 Link Here
119
            library_ids.push("[% library.branchcode | html %]");
119
            library_ids.push("[% library.branchcode | html %]");
120
        [% END %]
120
        [% END %]
121
    </script>
121
    </script>
122
123
    <script>
122
    <script>
124
        $(document).ready(function() {
123
        $(document).ready(function() {
125
            library_ids.forEach(library_id => {
124
            library_ids.forEach(library_id => {
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/view_holdsqueue.tt (-10 / +12 lines)
Lines 383-394 Link Here
383
    <script>
383
    <script>
384
        var table_settings = [% TablesSettings.GetTableSettings('circ', 'view_holdsqueue', 'holds-table', 'json') | $raw %];
384
        var table_settings = [% TablesSettings.GetTableSettings('circ', 'view_holdsqueue', 'holds-table', 'json') | $raw %];
385
    </script>
385
    </script>
386
387
    <script>
386
    <script>
388
        $(document).ready(function() {
387
        $(document).ready(function () {
389
            // Apply select2 to all select fields having a "multiple" attribute
388
            // Apply select2 to all select fields having a "multiple" attribute
390
            let selectFields = document.querySelectorAll('select[multiple]');
389
            let selectFields = document.querySelectorAll("select[multiple]");
391
            selectFields.forEach((selectField) => {
390
            selectFields.forEach(selectField => {
392
                $(selectField).select2({
391
                $(selectField).select2({
393
                    width: "100%",
392
                    width: "100%",
394
                    allowClear: true,
393
                    allowClear: true,
Lines 399-413 Link Here
399
            // Setup filters before DataTables initialisation, in case some columns are
398
            // Setup filters before DataTables initialisation, in case some columns are
400
            // hidden by default
399
            // hidden by default
401
            var filterColumnTimeoutId;
400
            var filterColumnTimeoutId;
402
            var filterColumn = function(e) {
401
            var filterColumn = function (e) {
403
                clearTimeout(filterColumnTimeoutId);
402
                clearTimeout(filterColumnTimeoutId);
404
                filterColumnTimeoutId = setTimeout(function() {
403
                filterColumnTimeoutId = setTimeout(function () {
405
                    var input = $(e.target);
404
                    var input = $(e.target);
406
                    var idx = input.parents('td').index();
405
                    var idx = input.parents("td").index();
407
                    holdst.api().column(idx + ':visible').search(input.val()).draw();
406
                    holdst
407
                        .api()
408
                        .column(idx + ":visible")
409
                        .search(input.val())
410
                        .draw();
408
                }, 200);
411
                }, 200);
409
            };
412
            };
410
            $('#holdst thead input').on('change keyup keydown', filterColumn);
413
            $("#holdst thead input").on("change keyup keydown", filterColumn);
411
414
412
            var holdst = $("#holdst").kohaTable(
415
            var holdst = $("#holdst").kohaTable(
413
                {
416
                {
Lines 417-423 Link Here
417
                },
420
                },
418
                table_settings
421
                table_settings
419
            );
422
            );
420
421
        });
423
        });
422
    </script>
424
    </script>
423
[% END %]
425
[% END %]
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/waitingreserves.tt (-46 / +43 lines)
Lines 209-218 Link Here
209
        var holdso_table_settings  = [% TablesSettings.GetTableSettings( 'circ', 'holds_awaiting_pickup', 'holdso',  'json' ) | $raw %];
209
        var holdso_table_settings  = [% TablesSettings.GetTableSettings( 'circ', 'holds_awaiting_pickup', 'holdso',  'json' ) | $raw %];
210
        var holdscr_table_settings = [% TablesSettings.GetTableSettings( 'circ', 'holds_awaiting_pickup', 'holdscr', 'json' ) | $raw %];
210
        var holdscr_table_settings = [% TablesSettings.GetTableSettings( 'circ', 'holds_awaiting_pickup', 'holdscr', 'json' ) | $raw %];
211
    </script>
211
    </script>
212
213
    <script>
212
    <script>
214
        var MSG_CANCEL_SELECTED = _("Cancel selected (%s)");
213
        var MSG_CANCEL_SELECTED = _("Cancel selected (%s)");
215
        $(document).ready(function() {
214
        $(document).ready(function () {
216
            $("#holdst").kohaTable(
215
            $("#holdst").kohaTable(
217
                {
216
                {
218
                    pagingType: "full",
217
                    pagingType: "full",
Lines 239-340 Link Here
239
238
240
            let cancel_link;
239
            let cancel_link;
241
240
242
            $("#cancelModalConfirmBtn").on("click",function(e) {
241
            $("#cancelModalConfirmBtn").on("click", function (e) {
243
                var ids = cancel_link.data('ids');
242
                var ids = cancel_link.data("ids");
244
                localStorage.selectedWaitingHolds = JSON.stringify(JSON.parse(localStorage.selectedWaitingHolds).filter(id => !ids.includes(id)));
243
                localStorage.selectedWaitingHolds = JSON.stringify(JSON.parse(localStorage.selectedWaitingHolds).filter(id => !ids.includes(id)));
245
                let link = `waitingreserves.pl?cancelBulk=1&amp;ids=${ids.join(',')}`;
244
                let link = `waitingreserves.pl?cancelBulk=1&amp;ids=${ids.join(",")}`;
246
                let reason = $("#modal-cancellation-reason").val();
245
                let reason = $("#modal-cancellation-reason").val();
247
                if ( reason ) {
246
                if (reason) {
248
                    link += "&amp;cancellation-reason=" + reason
247
                    link += "&amp;cancellation-reason=" + reason;
249
                }
248
                }
250
                window.location.href = link;
249
                window.location.href = link;
251
                return false;
250
                return false;
252
            });
251
            });
253
252
254
            if(!localStorage.selectedWaitingHolds || document.referrer.replace(/\?.*/, '') !== document.location.origin+document.location.pathname) {
253
            if (!localStorage.selectedWaitingHolds || document.referrer.replace(/\?.*/, "") !== document.location.origin + document.location.pathname) {
255
                localStorage.selectedWaitingHolds = '[]';
254
                localStorage.selectedWaitingHolds = "[]";
256
            }
255
            }
257
256
258
            try {
257
            try {
259
                JSON.parse(localStorage.selectedWaitingHolds);
258
                JSON.parse(localStorage.selectedWaitingHolds);
260
            } catch(e) {
259
            } catch (e) {
261
                localStorage.selectedWaitingHolds = '[]';
260
                localStorage.selectedWaitingHolds = "[]";
262
            }
261
            }
263
262
264
            $('.holds_table .select_hold').each(function() {
263
            $(".holds_table .select_hold").each(function () {
265
                if(JSON.parse(localStorage.selectedWaitingHolds).includes($(this).data('id'))) {
264
                if (JSON.parse(localStorage.selectedWaitingHolds).includes($(this).data("id"))) {
266
                    $(this).prop('checked', true);
265
                    $(this).prop("checked", true);
267
                }
266
                }
268
            });
267
            });
269
268
270
            function get_selected_ids(dt){
269
            function get_selected_ids(dt) {
271
                let selected_ids = [];
270
                let selected_ids = [];
272
                dt.cells(null, 0).every(function(){
271
                dt.cells(null, 0).every(function () {
273
                    let checkbox = $(this.node()).find('input[type="checkbox"]');
272
                    let checkbox = $(this.node()).find('input[type="checkbox"]');
274
                    if ( checkbox.is(':checked') ) {
273
                    if (checkbox.is(":checked")) {
275
                        selected_ids.push(checkbox.data('id'));
274
                        selected_ids.push(checkbox.data("id"));
276
                    }
275
                    }
277
                })
276
                });
278
                return selected_ids;
277
                return selected_ids;
279
            }
278
            }
280
279
281
            $('.holds_table').each(function() {
280
            $(".holds_table").each(function () {
282
                var parent = $(this).parents('.tab-pane');
281
                var parent = $(this).parents(".tab-pane");
283
                var this_dt = $(this).DataTable();
282
                var this_dt = $(this).DataTable();
284
                let selected_ids = get_selected_ids(this_dt);
283
                let selected_ids = get_selected_ids(this_dt);
285
                parent.find('.cancel_selected_holds').html(MSG_CANCEL_SELECTED.format(selected_ids.length));
284
                parent.find(".cancel_selected_holds").html(MSG_CANCEL_SELECTED.format(selected_ids.length));
286
                parent.find('.cancel_selected_holds').click(function(e) {
285
                parent.find(".cancel_selected_holds").click(function (e) {
287
                  e.preventDefault();
286
                    e.preventDefault();
288
                  if(get_selected_ids(this_dt).length) {
287
                    if (get_selected_ids(this_dt).length) {
289
                      cancel_link = $(this);
288
                        cancel_link = $(this);
290
                      $('#cancelModal').modal('show');
289
                        $("#cancelModal").modal("show");
291
                  }
290
                    }
292
                  return false;
291
                    return false;
293
                });
292
                });
294
            });
293
            });
295
294
296
            $('.holds_table').on('click', '.select_hold_all', function() {
295
            $(".holds_table").on("click", ".select_hold_all", function () {
297
                var parent = $(this).parents('.tab-pane');
296
                var parent = $(this).parents(".tab-pane");
298
                var this_dt = $(this).closest('.holds_table').DataTable();
297
                var this_dt = $(this).closest(".holds_table").DataTable();
299
298
300
                var all_checked = $(this).closest('.select_hold_all').prop('checked');
299
                var all_checked = $(this).closest(".select_hold_all").prop("checked");
301
300
302
                this_dt.cells(null, 0).every(function(){
301
                this_dt.cells(null, 0).every(function () {
303
                    $(this.node()).find('input[type="checkbox"]').prop('checked', all_checked)
302
                    $(this.node()).find('input[type="checkbox"]').prop("checked", all_checked);
304
                });
303
                });
305
304
306
                let selected_ids = get_selected_ids(this_dt);
305
                let selected_ids = get_selected_ids(this_dt);
307
                var count = selected_ids.length;
306
                var count = selected_ids.length;
308
                parent.find('.cancel_selected_holds').data('ids', selected_ids).html(MSG_CANCEL_SELECTED.format(count));
307
                parent.find(".cancel_selected_holds").data("ids", selected_ids).html(MSG_CANCEL_SELECTED.format(count));
309
                localStorage.selectedWaitingHolds = JSON.stringify(selected_ids);
308
                localStorage.selectedWaitingHolds = JSON.stringify(selected_ids);
310
            });
309
            });
311
310
312
            $('.holds_table').on('click', '.select_hold', function() {
311
            $(".holds_table").on("click", ".select_hold", function () {
313
                var parent = $(this).parents('.tab-pane');
312
                var parent = $(this).parents(".tab-pane");
314
                var this_dt = $(this).closest('.holds_table').DataTable();
313
                var this_dt = $(this).closest(".holds_table").DataTable();
315
                let selected_ids = get_selected_ids(this_dt);
314
                let selected_ids = get_selected_ids(this_dt);
316
                var count = selected_ids.length;
315
                var count = selected_ids.length;
317
                parent.find('.cancel_selected_holds').data('ids', selected_ids).html(MSG_CANCEL_SELECTED.format(count));
316
                parent.find(".cancel_selected_holds").data("ids", selected_ids).html(MSG_CANCEL_SELECTED.format(count));
318
                localStorage.selectedWaitingHolds = JSON.stringify(selected_ids);
317
                localStorage.selectedWaitingHolds = JSON.stringify(selected_ids);
319
            });
318
            });
320
319
321
            var hash = document.location.hash;
320
            var hash = document.location.hash;
322
            if( hash !== "" ){
321
            if (hash !== "") {
323
                /* The existence of location.hash means someone clicked a link which targets a specific tab */
322
                /* The existence of location.hash means someone clicked a link which targets a specific tab */
324
                $( hash ).tab("show");
323
                $(hash).tab("show");
325
            } else {
324
            } else {
326
                /* If no specific tab was linked to, use the last active tab */
325
                /* If no specific tab was linked to, use the last active tab */
327
                var activeTab = localStorage.getItem("waitingreserves_activetab");
326
                var activeTab = localStorage.getItem("waitingreserves_activetab");
328
                if( activeTab ){
327
                if (activeTab) {
329
                    $("div#resultlist li:eq(" + activeTab + ") a").tab("show");
328
                    $("div#resultlist li:eq(" + activeTab + ") a").tab("show");
330
                }
329
                }
331
            }
330
            }
332
            $("div#resultlist a[data-bs-toggle='tab']").on("shown.bs.tab", function (e) {
331
            $("div#resultlist a[data-bs-toggle='tab']").on("shown.bs.tab", function (e) {
333
                var thisTab = $(e.target).parent();
332
                var thisTab = $(e.target).parent();
334
                var activeTab = thisTab.index();
333
                var activeTab = thisTab.index();
335
                localStorage.setItem("waitingreserves_activetab", activeTab );
334
                localStorage.setItem("waitingreserves_activetab", activeTab);
336
            });
335
            });
337
338
        });
336
        });
339
    </script>
337
    </script>
340
[% END %]
338
[% END %]
341
- 

Return to bug 41568