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

(-)a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-account.tt (-63 / +57 lines)
Lines 86-197 Link Here
86
    <script>
86
    <script>
87
        const ENABLE_OPAC_PAYMENTS = [% ENABLE_OPAC_PAYMENTS ? 1 : 0 | html %];
87
        const ENABLE_OPAC_PAYMENTS = [% ENABLE_OPAC_PAYMENTS ? 1 : 0 | html %];
88
    </script>
88
    </script>
89
90
    <script>
89
    <script>
91
        $( document ).ready(function() {
90
        $(document).ready(function () {
92
93
            var txtActivefilter = _("Filter paid transactions");
91
            var txtActivefilter = _("Filter paid transactions");
94
            var txtInactivefilter = _("Show all transactions");
92
            var txtInactivefilter = _("Show all transactions");
95
93
96
            var fines_table = $("#finestable").kohaTable({
94
            var fines_table = $("#finestable").kohaTable({
97
                ...(ENABLE_OPAC_PAYMENTS
95
                ...(ENABLE_OPAC_PAYMENTS ? { order: [[1, "desc"]] } : { order: [[0, "desc"]] }),
98
                    ? {order: [[ 1, "desc" ]]}
96
                dom: '<"#filter_p">',
99
                    : {order: [[ 0, "desc" ]]}
97
                responsive: {
100
                ),
98
                    details: { type: "column", target: -1 },
101
                 dom: '<"#filter_p">',
99
                },
102
                 responsive: {
100
                columnDefs: [{ className: "dtr-control", orderable: false, targets: -1 }],
103
                    details: { "type": 'column',"target": -1 }
101
                drawCallback: function () {
104
                 },
102
                    show_hiddentfoot("#finestable");
105
                 columnDefs: [
103
                },
106
                    { className: 'dtr-control', orderable: false, targets: -1 }
104
            });
107
                 ],
108
                 drawCallback: function() {
109
                    show_hiddentfoot('#finestable');
110
                 }
111
            } );
112
105
113
            $('table[id^="finestable-"]').kohaTable({
106
            $('table[id^="finestable-"]').kohaTable({
114
                 responsive: {
107
                responsive: {
115
                    details: { "type": 'column',"target": -1 }
108
                    details: { type: "column", target: -1 },
116
                 },
109
                },
117
                 columnDefs: [
110
                columnDefs: [{ className: "dtr-control", orderable: false, targets: -1 }],
118
                    { className: 'dtr-control', orderable: false, targets: -1 }
111
                drawCallback: function () {
119
                 ],
120
                 drawCallback: function() {
121
                    show_hiddentfoot('table[id^="finestable-"]');
112
                    show_hiddentfoot('table[id^="finestable-"]');
122
                 }
113
                },
123
            });
114
            });
124
115
125
            function show_hiddentfoot(selector) {
116
            function show_hiddentfoot(selector) {
126
                $('.finestable tfoot .sum').show();
117
                $(".finestable tfoot .sum").show();
127
                if ($(".finestable tfoot td.dtr-hidden").length > 0) {
118
                if ($(".finestable tfoot td.dtr-hidden").length > 0) {
128
                    $(selector+" tfoot th").removeAttr( "colspan" );
119
                    $(selector + " tfoot th").removeAttr("colspan");
129
                    $(".finestable tfoot .dtr-control").hide();
120
                    $(".finestable tfoot .dtr-control").hide();
130
                }
121
                }
131
            }
122
            }
132
            $("#filter_p").html('<p><a href="#" id="filter_paid"><i class="fa fa-filter" aria-hidden="true"></i> '+txtActivefilter+'</a>');
123
            $("#filter_p").html('<p><a href="#" id="filter_paid"><i class="fa fa-filter" aria-hidden="true"></i> ' + txtActivefilter + "</a>");
133
            $('#filter_paid').click(function(e) {
124
            $("#filter_paid").click(function (e) {
134
                e.preventDefault();
125
                e.preventDefault();
135
                let filteredValue = '';
126
                let filteredValue = "";
136
                if ($(this).hasClass('filtered')) {
127
                if ($(this).hasClass("filtered")) {
137
                    $(this).html('<i class="fa fa-filter" aria-hidden="true"></i> '+txtActivefilter);
128
                    $(this).html('<i class="fa fa-filter" aria-hidden="true"></i> ' + txtActivefilter);
138
                } else { //Not filtered. Let's do it!
129
                } else {
139
                    filteredValue = '^((?!0.00).*)$'; //Filter not matching 0.00 http://stackoverflow.com/a/406408
130
                    //Not filtered. Let's do it!
140
                    $(this).html('<i class="fa fa-filter" aria-hidden="true"></i> '+txtInactivefilter);
131
                    filteredValue = "^((?!0.00).*)$"; //Filter not matching 0.00 http://stackoverflow.com/a/406408
132
                    $(this).html('<i class="fa fa-filter" aria-hidden="true"></i> ' + txtInactivefilter);
141
                }
133
                }
142
                fines_table.DataTable().columns(-2).search(filteredValue, {regex: true}).draw();
134
                fines_table.DataTable().columns(-2).search(filteredValue, { regex: true }).draw();
143
                $(this).toggleClass('filtered');
135
                $(this).toggleClass("filtered");
144
            });
136
            });
145
137
146
            //Start filtered
138
            //Start filtered
147
            $('#filter_paid').click();
139
            $("#filter_paid").click();
148
140
149
            $(".pay-online").removeClass("hidden");
141
            $(".pay-online").removeClass("hidden");
150
142
151
            $("#amount-to-pay-label").hide();
143
            $("#amount-to-pay-label").hide();
152
144
153
            $(".checkbox-pay, input[name='payment_method']").change( function() {
145
            $(".checkbox-pay, input[name='payment_method']").change(function () {
154
                // Disable the pay button if no fees are selected
146
                // Disable the pay button if no fees are selected
155
                //$("#submit-pay").prop("disabled", ! $(".checkbox-pay:checked").length );
147
                //$("#submit-pay").prop("disabled", ! $(".checkbox-pay:checked").length );
156
148
157
                // Calculate the total amount to be paid based on selected fees
149
                // Calculate the total amount to be paid based on selected fees
158
                var total = 0;
150
                var total = 0;
159
                $(".checkbox-pay").each( function() {
151
                $(".checkbox-pay").each(function () {
160
                    if ( $(this).is(":checked") ) {
152
                    if ($(this).is(":checked")) {
161
                        var id = this.id.split("checkbox-pay-")[1];
153
                        var id = this.id.split("checkbox-pay-")[1];
162
                        total += parseFloat( $("#amount-" + id).val() );
154
                        total += parseFloat($("#amount-" + id).val());
163
                    }
155
                    }
164
                });
156
                });
165
157
166
                var p = Promise.resolve();
158
                var p = Promise.resolve();
167
                if ( total ) {
159
                if (total) {
168
                    p = Promise.all(
160
                    p = Promise.all(
169
                        $('input[name="payment_method"]').map(function() {
161
                        $('input[name="payment_method"]')
170
                            var self = this;
162
                            .map(function () {
171
                            return new Promise(function(resolve, reject) {
163
                                var self = this;
172
                                var threshold = $(self).data('threshold');
164
                                return new Promise(function (resolve, reject) {
173
                                var help = $(self).parent().siblings('.help-block');
165
                                    var threshold = $(self).data("threshold");
174
                                if(!threshold || threshold == '' || threshold <= total) {
166
                                    var help = $(self).parent().siblings(".help-block");
175
                                    $(self).prop('disabled', false);
167
                                    if (!threshold || threshold == "" || threshold <= total) {
176
                                    help.addClass('hide');
168
                                        $(self).prop("disabled", false);
177
                                } else {
169
                                        help.addClass("hide");
178
                                    $(self).prop('disabled', true);
170
                                    } else {
179
                                    help.html( _("Minimum amount needed by this service is %s").format(parseInt(threshold,10).toFixed(2)) ).removeClass('hide');
171
                                        $(self).prop("disabled", true);
180
                                }
172
                                        help.html(_("Minimum amount needed by this service is %s").format(parseInt(threshold, 10).toFixed(2))).removeClass("hide");
181
                                resolve();
173
                                    }
174
                                    resolve();
175
                                });
182
                            })
176
                            })
183
                        }).toArray()
177
                            .toArray()
184
                    );
178
                    );
185
179
186
                    $("#amount-to-pay").html( total.toFixed(2) );
180
                    $("#amount-to-pay").html(total.toFixed(2));
187
                    $("#amount-to-pay-label").show();
181
                    $("#amount-to-pay-label").show();
188
                } else {
182
                } else {
189
                    $('input[name="payment_method"]').prop('disabled', false).parent().siblings('.help-block').addClass('hide');
183
                    $('input[name="payment_method"]').prop("disabled", false).parent().siblings(".help-block").addClass("hide");
190
                    $("#amount-to-pay-label").hide();
184
                    $("#amount-to-pay-label").hide();
191
                }
185
                }
192
                p.then(function() {
186
                p.then(function () {
193
                    $("#submit-pay").prop("disabled", ! $(".checkbox-pay:checked").length || ! $('input[name="payment_method"]:checked:not(:disabled)').length);
187
                    $("#submit-pay").prop("disabled", !$(".checkbox-pay:checked").length || !$('input[name="payment_method"]:checked:not(:disabled)').length);
194
                })
188
                });
195
            });
189
            });
196
        });
190
        });
197
    </script>
191
    </script>
(-)a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-basket.tt (-39 / +37 lines)
Lines 446-458 Link Here
446
    [% IF ( TagsInputEnabled && loggedinusername ) %]
446
    [% IF ( TagsInputEnabled && loggedinusername ) %]
447
        <script>
447
        <script>
448
            function tagSelected() {
448
            function tagSelected() {
449
                var bibs = document.getElementById('records').value;
449
                var bibs = document.getElementById("records").value;
450
                if (bibs) {
450
                if (bibs) {
451
                    $("#tagsel_tag").hide();
451
                    $("#tagsel_tag").hide();
452
                    $("#tag_hides").hide();
452
                    $("#tag_hides").hide();
453
                    $("#tagsel_form").show();
453
                    $("#tagsel_form").show();
454
                } else {
454
                } else {
455
                    alert( _("No item was selected") );
455
                    alert(_("No item was selected"));
456
                }
456
                }
457
            }
457
            }
458
458
Lines 467-479 Link Here
467
            function tagAdded() {
467
            function tagAdded() {
468
                var checkedBoxes = $("input:checkbox:checked");
468
                var checkedBoxes = $("input:checkbox:checked");
469
                if (!$(checkedBoxes).size()) {
469
                if (!$(checkedBoxes).size()) {
470
                    alert( _("No item was selected") );
470
                    alert(_("No item was selected"));
471
                    return false;
471
                    return false;
472
                }
472
                }
473
473
474
                var tag = $("#tagsel_new").val();
474
                var tag = $("#tagsel_new").val();
475
                if (!tag || (tag == "")) {
475
                if (!tag || tag == "") {
476
                    alert( _("No tag was specified.") );
476
                    alert(_("No tag was specified."));
477
                    return false;
477
                    return false;
478
                }
478
                }
479
479
Lines 488-607 Link Here
488
            }
488
            }
489
        </script>
489
        </script>
490
    [% END # / TagsInputEnabled && loggedinusername %]
490
    [% END # / TagsInputEnabled && loggedinusername %]
491
492
    <script>
491
    <script>
493
        $(document).ready(function(){
492
        $(document).ready(function () {
494
            $("a.bib_opener").on('click',function(){
493
            $("a.bib_opener").on("click", function () {
495
                let link = this.dataset.link;
494
                let link = this.dataset.link;
496
                let biblionumber = this.dataset.biblionumber;
495
                let biblionumber = this.dataset.biblionumber;
497
                openBiblio(link,biblionumber)
496
                openBiblio(link, biblionumber);
498
            });
497
            });
499
498
500
            $(".brief").click(function(e){
499
            $(".brief").click(function (e) {
501
                e.preventDefault();
500
                e.preventDefault();
502
                showLess();
501
                showLess();
503
            });
502
            });
504
503
505
            $(".detail").click(function(e){
504
            $(".detail").click(function (e) {
506
                e.preventDefault();
505
                e.preventDefault();
507
                showMore();
506
                showMore();
508
            });
507
            });
509
508
510
            $(".send").click(function(e){
509
            $(".send").click(function (e) {
511
                e.preventDefault();
510
                e.preventDefault();
512
                sendBasket();
511
                sendBasket();
513
            });
512
            });
514
513
515
            $(".download-cart").on("click", function(e){
514
            $(".download-cart").on("click", function (e) {
516
                e.preventDefault();
515
                e.preventDefault();
517
                var format = $(this).data("format");
516
                var format = $(this).data("format");
518
                $("#download_format").val( format );
517
                $("#download_format").val(format);
519
                $("#download_cart").submit();
518
                $("#download_cart").submit();
520
            });
519
            });
521
520
522
            $(".empty").click(function(e){
521
            $(".empty").click(function (e) {
523
                e.preventDefault();
522
                e.preventDefault();
524
                delBasket();
523
                delBasket();
525
            });
524
            });
526
525
527
            $(".deleteshelf").click(function(e){
526
            $(".deleteshelf").click(function (e) {
528
                e.preventDefault();
527
                e.preventDefault();
529
                delSelRecords();
528
                delSelRecords();
530
            });
529
            });
531
530
532
            $(".newshelf").click(function(e){
531
            $(".newshelf").click(function (e) {
533
                e.preventDefault();
532
                e.preventDefault();
534
                addSelToShelf();
533
                addSelToShelf();
535
            });
534
            });
536
535
537
            $(".hold").click(function(e){
536
            $(".hold").click(function (e) {
538
                e.preventDefault();
537
                e.preventDefault();
539
                holdSel();
538
                holdSel();
540
            });
539
            });
541
540
542
            $("#tagsel_tag").click(function(e){
541
            $("#tagsel_tag").click(function (e) {
543
                e.preventDefault();
542
                e.preventDefault();
544
                tagSelected();
543
                tagSelected();
545
            });
544
            });
546
545
547
            $("#tagsel_button").click(function(e){
546
            $("#tagsel_button").click(function (e) {
548
                e.preventDefault();
547
                e.preventDefault();
549
                tagAdded();
548
                tagAdded();
550
            });
549
            });
551
550
552
            $("#tagsel_cancel").click(function(e){
551
            $("#tagsel_cancel").click(function (e) {
553
                e.preventDefault();
552
                e.preventDefault();
554
                tagCanceled();
553
                tagCanceled();
555
            });
554
            });
556
555
557
            $("#CheckAll").click(function(e){
556
            $("#CheckAll").click(function (e) {
558
                e.preventDefault();
557
                e.preventDefault();
559
                $(".cb").each(function(){
558
                $(".cb").each(function () {
560
                    $(this).prop("checked", true);
559
                    $(this).prop("checked", true);
561
                    selRecord(this.value, true);
560
                    selRecord(this.value, true);
562
                });
561
                });
563
                enableCheckboxActions();
562
                enableCheckboxActions();
564
            });
563
            });
565
564
566
            $("#CheckNone").click(function(e){
565
            $("#CheckNone").click(function (e) {
567
                e.preventDefault();
566
                e.preventDefault();
568
                $(".cb").each(function(){
567
                $(".cb").each(function () {
569
                    $(this).prop("checked", false);
568
                    $(this).prop("checked", false);
570
                    selRecord(this.value, false);
569
                    selRecord(this.value, false);
571
                });
570
                });
572
                enableCheckboxActions();
571
                enableCheckboxActions();
573
            });
572
            });
574
573
575
            if( $("#itemst").length > 0 ){
574
            if ($("#itemst").length > 0) {
576
                var itemst = $("#itemst").kohaTable({
575
                var itemst = $("#itemst").kohaTable({
577
                    order: [[1, "asc"]],
576
                    order: [[1, "asc"]],
578
                });
577
                });
579
578
580
                var buttons = new $.fn.dataTable.Buttons(itemst, {
579
                var buttons = new $.fn.dataTable.Buttons(itemst, {
581
                     buttons: [
580
                    buttons: ["print"],
582
                        'print'
581
                })
583
                    ]
582
                    .container()
584
                }).container().appendTo($('#toolbar'));
583
                    .appendTo($("#toolbar"));
585
            }
584
            }
586
585
587
            $(".cb").change(function(){
586
            $(".cb").change(function () {
588
                selRecord( $(this).val(), $(this).prop("checked") );
587
                selRecord($(this).val(), $(this).prop("checked"));
589
                enableCheckboxActions();
588
                enableCheckboxActions();
590
                return false;
589
                return false;
591
            });
590
            });
592
            enableCheckboxActions();
591
            enableCheckboxActions();
593
594
        });
592
        });
595
593
596
        function enableCheckboxActions(){
594
        function enableCheckboxActions() {
597
            // Enable/disable controls if checkboxes are checked
595
            // Enable/disable controls if checkboxes are checked
598
            var checkedBoxes = $(".cb:checked");
596
            var checkedBoxes = $(".cb:checked");
599
            if ( checkedBoxes.length ) {
597
            if (checkedBoxes.length) {
600
              $(".selections").html(_("With selected titles: "));
598
                $(".selections").html(_("With selected titles: "));
601
              $(".selections-toolbar .links a").removeClass("disabled").attr("aria-disabled", "false");
599
                $(".selections-toolbar .links a").removeClass("disabled").attr("aria-disabled", "false");
602
            } else {
600
            } else {
603
              $(".selections").html(_("Select titles to: "));
601
                $(".selections").html(_("Select titles to: "));
604
              $(".selections-toolbar .links a").addClass("disabled").attr("aria-disabled", "true");
602
                $(".selections-toolbar .links a").addClass("disabled").attr("aria-disabled", "true");
605
            }
603
            }
606
        }
604
        }
607
    </script>
605
    </script>
(-)a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-course-details.tt (-7 / +3 lines)
Lines 144-153 Link Here
144
            OPACTableColExpandedByDefault: [% Koha.Preference('OPACTableColExpandedByDefault') ? 1 : 0 | html %],
144
            OPACTableColExpandedByDefault: [% Koha.Preference('OPACTableColExpandedByDefault') ? 1 : 0 | html %],
145
        });
145
        });
146
    </script>
146
    </script>
147
148
    <script>
147
    <script>
149
        $(document).ready(function() {
148
        $(document).ready(function () {
150
151
            var responsive_display = prefs.OPACTableColExpandedByDefault ? DataTable.Responsive.display.childRowImmediate : DataTable.Responsive.display.childRow;
149
            var responsive_display = prefs.OPACTableColExpandedByDefault ? DataTable.Responsive.display.childRowImmediate : DataTable.Responsive.display.childRow;
152
            $("#course-items-table").kohaTable(
150
            $("#course-items-table").kohaTable(
153
                {
151
                {
Lines 161-172 Link Here
161
                        details: {
159
                        details: {
162
                            display: responsive_display,
160
                            display: responsive_display,
163
                            type: "column",
161
                            type: "column",
164
                            target: -1
162
                            target: -1,
165
                        },
163
                        },
166
                    },
164
                    },
167
                    columnDefs: [
165
                    columnDefs: [{ className: "dtr-control", orderable: false, targets: -1 }],
168
                        { className: "dtr-control", orderable: false, targets: -1 },
169
                    ],
170
                },
166
                },
171
                table_settings
167
                table_settings
172
            );
168
            );
(-)a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-course-reserves.tt (-6 / +3 lines)
Lines 89-97 Link Here
89
            OPACTableColExpandedByDefault: [% Koha.Preference('OPACTableColExpandedByDefault') ? 1 : 0 | html %],
89
            OPACTableColExpandedByDefault: [% Koha.Preference('OPACTableColExpandedByDefault') ? 1 : 0 | html %],
90
        });
90
        });
91
    </script>
91
    </script>
92
93
    <script>
92
    <script>
94
        $(document).ready(function() {
93
        $(document).ready(function () {
95
            var responsive_display = prefs.OPACTableColExpandedByDefault ? DataTable.Responsive.display.childRowImmediate : DataTable.Responsive.display.childRow;
94
            var responsive_display = prefs.OPACTableColExpandedByDefault ? DataTable.Responsive.display.childRowImmediate : DataTable.Responsive.display.childRow;
96
            $("#course_reserves_table").kohaTable(
95
            $("#course_reserves_table").kohaTable(
97
                {
96
                {
Lines 106-117 Link Here
106
                        details: {
105
                        details: {
107
                            display: responsive_display,
106
                            display: responsive_display,
108
                            type: "column",
107
                            type: "column",
109
                            target: -1
108
                            target: -1,
110
                        },
109
                        },
111
                    },
110
                    },
112
                    cColumnDefs: [
111
                    cColumnDefs: [{ className: "dtr-control", orderable: false, targets: -1 }],
113
                        { className: "dtr-control", orderable: false, targets: -1 },
114
                    ],
115
                },
112
                },
116
                table_settings
113
                table_settings
117
            );
114
            );
(-)a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-curbside-pickups.tt (-94 / +98 lines)
Lines 326-345 Link Here
326
            OPACTableColExpandedByDefault: [% Koha.Preference('OPACTableColExpandedByDefault') ? 1 : 0 | html %],
326
            OPACTableColExpandedByDefault: [% Koha.Preference('OPACTableColExpandedByDefault') ? 1 : 0 | html %],
327
        });
327
        });
328
    </script>
328
    </script>
329
330
    <script>
329
    <script>
331
        let existingPickupMoments = [];
330
        let existingPickupMoments = [];
332
        pickups.forEach(function(pickup){
331
        pickups.forEach(function (pickup) {
333
            let scheduled_pickup_datetime = pickup.scheduled_pickup_datetime;
332
            let scheduled_pickup_datetime = pickup.scheduled_pickup_datetime;
334
            let pickupMoment = dayjs(scheduled_pickup_datetime);
333
            let pickupMoment = dayjs(scheduled_pickup_datetime);
335
334
336
            if(!existingPickupMoments[pickup.branchcode]) existingPickupMoments[pickup.branchcode] = [];
335
            if (!existingPickupMoments[pickup.branchcode]) existingPickupMoments[pickup.branchcode] = [];
337
            existingPickupMoments[pickup.branchcode].push(pickupMoment);
336
            existingPickupMoments[pickup.branchcode].push(pickupMoment);
338
        });
337
        });
339
338
340
        var responsive_display = prefs.OPACTableColExpandedByDefault ? DataTable.Responsive.display.childRowImmediate : DataTable.Responsive.display.childRow;
339
        var responsive_display = prefs.OPACTableColExpandedByDefault ? DataTable.Responsive.display.childRowImmediate : DataTable.Responsive.display.childRow;
341
340
342
        $(document).ready(function() {
341
        $(document).ready(function () {
343
            $("#pickups-table").kohaTable({
342
            $("#pickups-table").kohaTable({
344
                searching: false,
343
                searching: false,
345
                paging: false,
344
                paging: false,
Lines 348-360 Link Here
348
                    details: {
347
                    details: {
349
                        display: responsive_display,
348
                        display: responsive_display,
350
                        type: "column",
349
                        type: "column",
351
                        target: -1
350
                        target: -1,
352
                    },
351
                    },
353
                },
352
                },
354
                columnDefs: [{ className: "dtr-control", orderable: false, targets: -1 }],
353
                columnDefs: [{ className: "dtr-control", orderable: false, targets: -1 }],
355
            });
354
            });
356
            $("#pickup-branch option").each(function(){
355
            $("#pickup-branch option").each(function () {
357
                if ( $(this).val() != "" && !policies[$(this).val()].enabled ) {
356
                if ($(this).val() != "" && !policies[$(this).val()].enabled) {
358
                    $(this).prop("disabled", "disabled");
357
                    $(this).prop("disabled", "disabled");
359
                    $(this).attr("title", _("You don't have waiting holds at this library"));
358
                    $(this).attr("title", _("You don't have waiting holds at this library"));
360
                }
359
                }
Lines 362-396 Link Here
362
361
363
            const pickupDate_fp = document.getElementById("pickup-date")._flatpickr;
362
            const pickupDate_fp = document.getElementById("pickup-date")._flatpickr;
364
363
365
            $('#pickup-branch').on('change', function() {
364
            $("#pickup-branch").on("change", function () {
366
                let branchcode = $(this).val();
365
                let branchcode = $(this).val();
367
366
368
                let existing_pickup = pickup_exists_in.indexOf(branchcode) != -1;
367
                let existing_pickup = pickup_exists_in.indexOf(branchcode) != -1;
369
368
370
                $('#pickup-date').val("");
369
                $("#pickup-date").val("");
371
                $('#pickup-time').val("");
370
                $("#pickup-time").val("");
372
                $('#pickup-times').hide();
371
                $("#pickup-times").hide();
373
                $('#schedule-pickup-button').prop('disabled', true);
372
                $("#schedule-pickup-button").prop("disabled", true);
374
373
375
                if (existing_pickup) {
374
                if (existing_pickup) {
376
                    $('#existing-pickup-warning').show();
375
                    $("#existing-pickup-warning").show();
377
                    $("#pickup-date,#pickup_date_item,#pickup_notes_item").hide();
376
                    $("#pickup-date,#pickup_date_item,#pickup_notes_item").hide();
378
                } else {
377
                } else {
379
                    $('#existing-pickup-warning').hide();
378
                    $("#existing-pickup-warning").hide();
380
                    $("#pickup-date,#pickup_date_item").show();
379
                    $("#pickup-date,#pickup_date_item").show();
381
                }
380
                }
382
381
383
                pickupDate_fp.set('disable', [function(date) {
382
                pickupDate_fp.set("disable", [
384
                    return !policies[branchcode].slots_per_day.hasOwnProperty(date.getDay());
383
                    function (date) {
385
                }]);
384
                        return !policies[branchcode].slots_per_day.hasOwnProperty(date.getDay());
386
385
                    },
386
                ]);
387
            });
387
            });
388
388
389
            pickupDate_fp.config.onClose.push(function( selectedDates, dateStr, instance ){
389
            pickupDate_fp.config.onClose.push(function (selectedDates, dateStr, instance) {
390
                /* Here we add an onClose event to the existing flatpickr instance */
390
                /* Here we add an onClose event to the existing flatpickr instance */
391
                /* It fires after the user has selected a date from the calendar popup */
391
                /* It fires after the user has selected a date from the calendar popup */
392
                $('#pickup-times').html("<label>" + _("Select a time") + ":</label><div id=\"pickup-time-slots\"></div>");
392
                $("#pickup-times").html("<label>" + _("Select a time") + ':</label><div id="pickup-time-slots"></div>');
393
                $('#schedule-pickup-button').prop( 'disabled', 1 );
393
                $("#schedule-pickup-button").prop("disabled", 1);
394
394
395
                var currentDate = dateStr;
395
                var currentDate = dateStr;
396
                let branchcode = $("#pickup-branch").val();
396
                let branchcode = $("#pickup-branch").val();
Lines 401-482 Link Here
401
                let pickupSlots = [];
401
                let pickupSlots = [];
402
                let available_count = 0;
402
                let available_count = 0;
403
                let dow = selectedDate.day(); // Sunday is 0 (at least for now)
403
                let dow = selectedDate.day(); // Sunday is 0 (at least for now)
404
                if (!policy.slots_per_day[dow]){
404
                if (!policy.slots_per_day[dow]) {
405
                    $('#pickup-times').html("<div>"+_("No pickup time defined for this day.")+"</div>");
405
                    $("#pickup-times").html("<div>" + _("No pickup time defined for this day.") + "</div>");
406
                    return;
406
                    return;
407
                }
407
                }
408
408
409
                policy.slots_per_day[dow].sort((a, b) => a.start_hour - b.start_hour).forEach(function(slot){
409
                policy.slots_per_day[dow]
410
                    let pickup_interval = policy.pickup_interval;
410
                    .sort((a, b) => a.start_hour - b.start_hour)
411
                    if (!pickup_interval) {
411
                    .forEach(function (slot) {
412
                        $('#pickup-times').html("<div>"+_("No pickup time defined for this day.")+"</div>");
412
                        let pickup_interval = policy.pickup_interval;
413
                        return;
413
                        if (!pickup_interval) {
414
                    }
414
                            $("#pickup-times").html("<div>" + _("No pickup time defined for this day.") + "</div>");
415
415
                            return;
416
                    let listStartMoment = selectedDate.hour(slot.start_hour).minute(slot.start_minute);
417
                    let listEndMoment = selectedDate.hour(slot.end_hour).minute(slot.end_minute);
418
419
                    let keep_going = true;
420
                    let now = dayjs();
421
422
                    // Initialize pickup slots starting at opening time
423
                    let pickupIntervalStartMoment = listStartMoment;
424
                    let pickupIntervalEndMoment   = listStartMoment.add(pickup_interval, 'minutes');
425
                    while (keep_going) {
426
                        let available = true;
427
                        let display_slot = true;
428
429
                        if (pickupIntervalStartMoment.isBefore(now)) {
430
                            // Slots in the past are unavailable
431
                            available = false;
432
                            display_slot = false;
433
                        }
434
435
                        if (pickupIntervalEndMoment.isAfter(listEndMoment)) {
436
                            // Slots after the end of pickup times for the day are unavailable
437
                            available = false;
438
                        }
439
440
                        let pickups_scheduled = 0;
441
442
                        if (existingPickupMoments[branchcode]){
443
                            existingPickupMoments[branchcode].forEach(function(pickupMoment){
444
                                // An existing pickup time
445
                                if (pickupMoment.isSameOrAfter(pickupIntervalStartMoment) && pickupMoment.isBefore(pickupIntervalEndMoment)) {
446
                                    // This calculated pickup is in use by another scheduled pickup
447
                                    pickups_scheduled++;
448
                                }
449
                            });
450
                        }
451
452
                        if (pickups_scheduled >= policy.patrons_per_interval) {
453
                            available = false;
454
                        }
455
456
                        if ( display_slot ) {
457
                            pickupSlots.push(
458
                                {
459
                                    "available": available,
460
                                    "moment": pickupIntervalStartMoment,
461
                                    "pickups_scheduled": pickups_scheduled
462
                                }
463
                            );
464
                        }
465
466
                        if ( available ) {
467
                            available_count++;
468
                        }
416
                        }
469
417
470
                        pickupIntervalStartMoment = pickupIntervalEndMoment;
418
                        let listStartMoment = selectedDate.hour(slot.start_hour).minute(slot.start_minute);
471
                        pickupIntervalEndMoment = pickupIntervalStartMoment.add(pickup_interval, 'minutes');
419
                        let listEndMoment = selectedDate.hour(slot.end_hour).minute(slot.end_minute);
472
                        if (pickupIntervalEndMoment.isAfter(listEndMoment)) {
420
473
                            // This latest slot is after the end of pickup times for the day, so we can stop
421
                        let keep_going = true;
474
                            keep_going = false;
422
                        let now = dayjs();
423
424
                        // Initialize pickup slots starting at opening time
425
                        let pickupIntervalStartMoment = listStartMoment;
426
                        let pickupIntervalEndMoment = listStartMoment.add(pickup_interval, "minutes");
427
                        while (keep_going) {
428
                            let available = true;
429
                            let display_slot = true;
430
431
                            if (pickupIntervalStartMoment.isBefore(now)) {
432
                                // Slots in the past are unavailable
433
                                available = false;
434
                                display_slot = false;
435
                            }
436
437
                            if (pickupIntervalEndMoment.isAfter(listEndMoment)) {
438
                                // Slots after the end of pickup times for the day are unavailable
439
                                available = false;
440
                            }
441
442
                            let pickups_scheduled = 0;
443
444
                            if (existingPickupMoments[branchcode]) {
445
                                existingPickupMoments[branchcode].forEach(function (pickupMoment) {
446
                                    // An existing pickup time
447
                                    if (pickupMoment.isSameOrAfter(pickupIntervalStartMoment) && pickupMoment.isBefore(pickupIntervalEndMoment)) {
448
                                        // This calculated pickup is in use by another scheduled pickup
449
                                        pickups_scheduled++;
450
                                    }
451
                                });
452
                            }
453
454
                            if (pickups_scheduled >= policy.patrons_per_interval) {
455
                                available = false;
456
                            }
457
458
                            if (display_slot) {
459
                                pickupSlots.push({
460
                                    available: available,
461
                                    moment: pickupIntervalStartMoment,
462
                                    pickups_scheduled: pickups_scheduled,
463
                                });
464
                            }
465
466
                            if (available) {
467
                                available_count++;
468
                            }
469
470
                            pickupIntervalStartMoment = pickupIntervalEndMoment;
471
                            pickupIntervalEndMoment = pickupIntervalStartMoment.add(pickup_interval, "minutes");
472
                            if (pickupIntervalEndMoment.isAfter(listEndMoment)) {
473
                                // This latest slot is after the end of pickup times for the day, so we can stop
474
                                keep_going = false;
475
                            }
475
                        }
476
                        }
476
                    }
477
477
478
                    $('#schedule-pickup-button').prop( 'disabled', available_count <= 0 );
478
                        $("#schedule-pickup-button").prop("disabled", available_count <= 0);
479
                });
479
                    });
480
480
481
                for (let i = 0; i < pickupSlots.length; i++) {
481
                for (let i = 0; i < pickupSlots.length; i++) {
482
                    let pickupSlot = pickupSlots[i];
482
                    let pickupSlot = pickupSlots[i];
Lines 485-491 Link Here
485
                    let pickups_scheduled = pickupSlot.pickups_scheduled;
485
                    let pickups_scheduled = pickupSlot.pickups_scheduled;
486
                    let pickups_available = policy.patrons_per_interval - pickups_scheduled;
486
                    let pickups_available = policy.patrons_per_interval - pickups_scheduled;
487
                    let disabled = pickupSlot.available ? "" : "disabled";
487
                    let disabled = pickupSlot.available ? "" : "disabled";
488
                    $("#pickup-time-slots").append(`<span class="pickup_time"><input type="radio" id="slot_${i}" name="pickup_time" value="${optValue}" ${disabled} /> <label class="pickup_select" for="slot_${i}" data-bs-toggle="tooltip" title="` + _("Appointments available: ") + `${pickups_available}">${optText} <span class="pickups_available">${pickups_available}</span></label></span>`);
488
                    $("#pickup-time-slots").append(
489
                        `<span class="pickup_time"><input type="radio" id="slot_${i}" name="pickup_time" value="${optValue}" ${disabled} /> <label class="pickup_select" for="slot_${i}" data-bs-toggle="tooltip" title="` +
490
                            _("Appointments available: ") +
491
                            `${pickups_available}">${optText} <span class="pickups_available">${pickups_available}</span></label></span>`
492
                    );
489
                }
493
                }
490
494
491
                $("#pickup_notes_item,#pickup-times").show();
495
                $("#pickup_notes_item,#pickup-times").show();
Lines 493-507 Link Here
493
497
494
            $("#pickup_date_item,#pickup_notes_item,#pickup-times").hide();
498
            $("#pickup_date_item,#pickup_notes_item,#pickup-times").hide();
495
499
496
            $("#create-pickup").on('submit', function(){
500
            $("#create-pickup").on("submit", function () {
497
                if ( ! $("input[type='radio']:checked").length ) {
501
                if (!$("input[type='radio']:checked").length) {
498
                    alert(_("Please select a date and a pickup time"));
502
                    alert(_("Please select a date and a pickup time"));
499
                    return false;
503
                    return false;
500
                }
504
                }
501
                return true;
505
                return true;
502
            });
506
            });
503
            $("#pickup-times").tooltip({
507
            $("#pickup-times").tooltip({
504
                selector: ".pickup_select"
508
                selector: ".pickup_select",
505
            });
509
            });
506
        });
510
        });
507
    </script>
511
    </script>
(-)a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-detail.tt (-3 lines)
Lines 1700-1706 Link Here
1700
1700
1701
        const defaulttab = "[% defaulttab | html %]";
1701
        const defaulttab = "[% defaulttab | html %]";
1702
    </script>
1702
    </script>
1703
1704
    <script>
1703
    <script>
1705
        window.emojiPicker = new EmojiPicker({
1704
        window.emojiPicker = new EmojiPicker({
1706
        emojiable_selector: '[data-emojiable=true]',
1705
        emojiable_selector: '[data-emojiable=true]',
Lines 2261-2267 Link Here
2261
2260
2262
        }
2261
        }
2263
    </script>
2262
    </script>
2264
2265
    [% IF ( NovelistSelectProfile && ( normalized_isbn || normalized_upc ) ) %]
2263
    [% IF ( NovelistSelectProfile && ( normalized_isbn || normalized_upc ) ) %]
2266
        <script>
2264
        <script>
2267
            $(document).ready(function() {
2265
            $(document).ready(function() {
Lines 2282-2286 Link Here
2282
            });
2280
            });
2283
        </script>
2281
        </script>
2284
    [% END %]
2282
    [% END %]
2285
2286
[% END %]
2283
[% END %]
(-)a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-full-serial-issues.tt (-53 / +56 lines)
Lines 193-222 Link Here
193
    <script>
193
    <script>
194
        const min_year = "[% yearmin | html %]";
194
        const min_year = "[% yearmin | html %]";
195
    </script>
195
    </script>
196
197
    <script>
196
    <script>
198
        $(document).ready(function(){
197
        $(document).ready(function () {
199
            showlayer(min_year);
198
            showlayer(min_year);
200
            $("a.tabsubs:first").addClass("currentsubtab");
199
            $("a.tabsubs:first").addClass("currentsubtab");
201
            $("#filterform").submit(function(){
200
            $("#filterform").submit(function () {
202
                filterByLibrary();
201
                filterByLibrary();
203
                return false;
202
                return false;
204
            });
203
            });
205
            $("#libraryfilter").change(function(){
204
            $("#libraryfilter").change(function () {
206
                filterByLibrary();
205
                filterByLibrary();
207
            });
206
            });
208
            $("#subscriptionidfilter").change(function(){
207
            $("#subscriptionidfilter").change(function () {
209
                filterBySubscriptionId();
208
                filterBySubscriptionId();
210
            });
209
            });
211
            $("#reset").click(function(){
210
            $("#reset").click(function () {
212
                clearFilters();
211
                clearFilters();
213
            });
212
            });
214
            $("a.tabsubs").on("click", function(e){
213
            $("a.tabsubs").on("click", function (e) {
215
                e.preventDefault();
214
                e.preventDefault();
216
                let year = $(this).data("year");
215
                let year = $(this).data("year");
217
                $("a.tabsubs").removeClass("currentsubtab");
216
                $("a.tabsubs").removeClass("currentsubtab");
218
                $(this).addClass("currentsubtab");
217
                $(this).addClass("currentsubtab");
219
                showlayer( year );
218
                showlayer(year);
220
            });
219
            });
221
            $(".subscriptionstclass").kohaTable({
220
            $(".subscriptionstclass").kohaTable({
222
                order: [[0, "desc"]],
221
                order: [[0, "desc"]],
Lines 230-302 Link Here
230
229
231
            // Getting each branchcode from the currently displayed tab
230
            // Getting each branchcode from the currently displayed tab
232
            var subarray = [];
231
            var subarray = [];
233
            $("div#" + currentYear + " table.subscriptionstclass tbody tr:visible td.libraryfilterclass").each(function() {
232
            $("div#" + currentYear + " table.subscriptionstclass tbody tr:visible td.libraryfilterclass").each(function () {
234
                if (subarray.indexOf($(this).text()) == -1) { subarray.push($(this).text()); }
233
                if (subarray.indexOf($(this).text()) == -1) {
234
                    subarray.push($(this).text());
235
                }
235
            });
236
            });
236
237
237
            // Setting the option values with branchcodes
238
            // Setting the option values with branchcodes
238
            $("#libraryfilter").append('<option value="all">'+_("(All)")+'</option>');
239
            $("#libraryfilter").append('<option value="all">' + _("(All)") + "</option>");
239
            for (var i = 0; i < subarray.length; i++) {
240
            for (var i = 0; i < subarray.length; i++) {
240
                $("#libraryfilter").append('<option value="' + subarray[i] + '">' + subarray[i] + '</option>');
241
                $("#libraryfilter").append('<option value="' + subarray[i] + '">' + subarray[i] + "</option>");
241
            }
242
            }
242
        }
243
        }
243
244
244
        // Filter by Library
245
        // Filter by Library
245
        function filterByLibrary() {
246
        function filterByLibrary() {
246
247
            selectedStatus = $("#libraryfilter").val();
247
            selectedStatus = $("#libraryfilter").val();
248
248
249
            // Reset the filters but keeps the selected library
249
            // Reset the filters but keeps the selected library
250
            clearFilters(true);
250
            clearFilters(true);
251
251
252
            if (selectedStatus != 'all') {
252
            if (selectedStatus != "all") {
253
254
                // We hide everything
253
                // We hide everything
255
            $("table.subscriptionstclass tbody tr").hide();
254
                $("table.subscriptionstclass tbody tr").hide();
256
255
257
            // Then show the lines that match the currently selected library
256
                // Then show the lines that match the currently selected library
258
            $("table.subscriptionstclass tbody tr td.libraryfilterclass:contains(" + selectedStatus + ")").parent().show();
257
                $("table.subscriptionstclass tbody tr td.libraryfilterclass:contains(" + selectedStatus + ")")
258
                    .parent()
259
                    .show();
259
260
261
                // We then prepare the subscription filter :
260
262
261
            // We then prepare the subscription filter :
263
                // Getting subscription id's for the selected library
262
264
                var subarray = [];
263
            // Getting subscription id's for the selected library
265
                $("div#" + currentYear + " table.subscriptionstclass tbody tr:visible td.subscriptionidfilterclass").each(function () {
264
            var subarray = [];
266
                    if (subarray.indexOf($(this).text()) == -1) {
265
            $("div#" + currentYear + " table.subscriptionstclass tbody tr:visible td.subscriptionidfilterclass").each(function() {
267
                        subarray.push($(this).text());
266
                if (subarray.indexOf($(this).text()) == -1) { subarray.push($(this).text()); }
268
                    }
267
            });
269
                });
268
            // Setting the option values with subscription id's
270
                // Setting the option values with subscription id's
269
            $("#subscriptionidfilter").append('<option value="all">'+_("(All)")+'</option>');
271
                $("#subscriptionidfilter").append('<option value="all">' + _("(All)") + "</option>");
270
            for (var i = 0; i < subarray.length; i++) {
272
                for (var i = 0; i < subarray.length; i++) {
271
                $("#subscriptionidfilter").append('<option value="' + subarray[i] + '">' + subarray[i] + '</option>');
273
                    $("#subscriptionidfilter").append('<option value="' + subarray[i] + '">' + subarray[i] + "</option>");
272
            }
274
                }
273
275
274
            // Subscription filtering is now ready
276
                // Subscription filtering is now ready
275
            $("#subscriptionidfilter").removeAttr("disabled");
277
                $("#subscriptionidfilter").removeAttr("disabled");
276
            }
278
            }
277
        }
279
        }
278
280
279
        // Filter by subscription id
281
        // Filter by subscription id
280
        function filterBySubscriptionId() {
282
        function filterBySubscriptionId() {
281
282
            selectedSubscription = $("#subscriptionidfilter").val();
283
            selectedSubscription = $("#subscriptionidfilter").val();
283
            selectedLibrary      = $("#libraryfilter").val();
284
            selectedLibrary = $("#libraryfilter").val();
284
285
285
            if (selectedSubscription == "all") {
286
            if (selectedSubscription == "all") {
286
            clearFilters(true);
287
                clearFilters(true);
287
            filterByLibrary();
288
                filterByLibrary();
288
            } else {
289
            } else {
290
                // We hide everything
291
                $("table.subscriptionstclass tbody tr").hide();
289
292
290
            // We hide everything
293
                // Then show the lines that match the currently selected library
291
            $("table.subscriptionstclass tbody tr").hide();
294
                $("table.subscriptionstclass tbody tr td.libraryfilterclass:contains(" + selectedLibrary + ")")
292
295
                    .parent()
293
            // Then show the lines that match the currently selected library
296
                    .show();
294
            $("table.subscriptionstclass tbody tr td.libraryfilterclass:contains(" + selectedLibrary + ")").parent().show();
295
297
296
            // Then hide the lines where the subscription id does not match the selected one
298
                // Then hide the lines where the subscription id does not match the selected one
297
            $("table.subscriptionstclass tbody tr td.subscriptionidfilterclass").not(
299
                $("table.subscriptionstclass tbody tr td.subscriptionidfilterclass")
298
                $("table.subscriptionstclass tbody tr td.subscriptionidfilterclass:contains(" + selectedSubscription + ")")
300
                    .not($("table.subscriptionstclass tbody tr td.subscriptionidfilterclass:contains(" + selectedSubscription + ")"))
299
            ).parent().hide();
301
                    .parent()
302
                    .hide();
300
            }
303
            }
301
        }
304
        }
302
305
Lines 308-330 Link Here
308
311
309
            // Remove old subscription options
312
            // Remove old subscription options
310
            $("#subscriptionidfilter option").remove();
313
            $("#subscriptionidfilter option").remove();
311
            $("#subscriptionidfilter option").append('<option value="all">'+_("(All)")+'</option>');
314
            $("#subscriptionidfilter option").append('<option value="all">' + _("(All)") + "</option>");
312
            $("#subscriptionidfilter").attr("disabled", "disabled");
315
            $("#subscriptionidfilter").attr("disabled", "disabled");
313
316
314
            if (keeplibrary != true) {
317
            if (keeplibrary != true) {
315
            // Reinit library options
318
                // Reinit library options
316
            initFilters();
319
                initFilters();
317
            $("#libraryfilter option[value=all]").attr("selected", "selected");
320
                $("#libraryfilter option[value=all]").attr("selected", "selected");
318
            }
321
            }
319
        }
322
        }
320
323
321
        function showlayer(numlayer){
324
        function showlayer(numlayer) {
322
            $(".yeardata").each(function(){
325
            $(".yeardata").each(function () {
323
                ong = $(this).attr("id");
326
                ong = $(this).attr("id");
324
                if(ong == "show"+numlayer){
327
                if (ong == "show" + numlayer) {
325
                    $(this).show();
328
                    $(this).show();
326
                    currentYear = ong;
329
                    currentYear = ong;
327
                } else  {
330
                } else {
328
                    $(this).hide();
331
                    $(this).hide();
329
                }
332
                }
330
            });
333
            });
(-)a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-illrequests.tt (-36 / +33 lines)
Lines 422-523 Link Here
422
            var metadata = "[% metadata | $raw %]";
422
            var metadata = "[% metadata | $raw %]";
423
        [% END %]
423
        [% END %]
424
    </script>
424
    </script>
425
426
    <script>
425
    <script>
427
        function display_extended_attribute(row, type) {
426
        function display_extended_attribute(row, type) {
428
            var arr = $.grep(row.extended_attributes, ( x => x.type === type ));
427
            var arr = $.grep(row.extended_attributes, x => x.type === type);
429
            if (arr.length > 0) {
428
            if (arr.length > 0) {
430
                return escape_str(arr[0].value);
429
                return escape_str(arr[0].value);
431
            }
430
            }
432
431
433
            return '';
432
            return "";
434
        }
433
        }
435
434
436
        function display_request_status(row) {
435
        function display_request_status(row) {
437
            let status       = row._strings.status.str;
436
            let status = row._strings.status.str;
438
            let status_alias = row._strings.status_av ?
437
            let status_alias = row._strings.status_av ? (row._strings.status_av.str ? row._strings.status_av.str : row._strings.status_av.code) : null;
439
                                    row._strings.status_av.str ?
440
                                        row._strings.status_av.str :
441
                                    row._strings.status_av.code :
442
                               null;
443
438
444
            let status_label = status + (status_alias ? " <i><strong>"+status_alias+"</strong></i>" : "");
439
            let status_label = status + (status_alias ? " <i><strong>" + status_alias + "</strong></i>" : "");
445
440
446
            return status_label;
441
            return status_label;
447
        }
442
        }
448
        $("#illrequestlist").kohaTable({
443
        $("#illrequestlist").kohaTable({
449
            order: [[ 0, "desc" ]],
444
            order: [[0, "desc"]],
450
            dom: '<"dt-info"i><"top pager"<"table_entries"lp>t<"bottom pager"pi>',
445
            dom: '<"dt-info"i><"top pager"<"table_entries"lp>t<"bottom pager"pi>',
451
            paging: true,
446
            paging: true,
452
            embed: ['+strings','extended_attributes'],
447
            embed: ["+strings", "extended_attributes"],
453
            ajax: { url: `/api/v1/public/patrons/${logged_in_user_borrowernumber}/ill/requests` },
448
            ajax: { url: `/api/v1/public/patrons/${logged_in_user_borrowernumber}/ill/requests` },
454
            columnDefs: [ {
449
            columnDefs: [
455
                render: function (data, type, row, meta) {
450
                {
456
                    if ( data && type == 'display' ) {
451
                    render: function (data, type, row, meta) {
457
                        return data.escapeHtml();
452
                        if (data && type == "display") {
458
                    }
453
                            return data.escapeHtml();
459
                    return data;
454
                        }
460
                }
455
                        return data;
461
            } ],
456
                    },
457
                },
458
            ],
462
            columns: [
459
            columns: [
463
                {
460
                {
464
                    data: 'ill_request_id',
461
                    data: "ill_request_id",
465
                    sortable: true
462
                    sortable: true,
466
                },
463
                },
467
                {
464
                {
468
                    data: 'author',
465
                    data: "author",
469
                    sortable: false,
466
                    sortable: false,
470
                    render: (data, type, row, meta) => {
467
                    render: (data, type, row, meta) => {
471
                        return display_extended_attribute(row, 'author');
468
                        return display_extended_attribute(row, "author");
472
                    },
469
                    },
473
                },
470
                },
474
                {
471
                {
475
                    data: 'title',
472
                    data: "title",
476
                    sortable: false,
473
                    sortable: false,
477
                    render: (data, type, row, meta) => {
474
                    render: (data, type, row, meta) => {
478
                        return display_extended_attribute(row, 'title');
475
                        return display_extended_attribute(row, "title");
479
                    },
476
                    },
480
                },
477
                },
481
                {
478
                {
482
                    data: 'ill_backend_id',
479
                    data: "ill_backend_id",
483
                    sortable: true
480
                    sortable: true,
484
                },
481
                },
485
                {
482
                {
486
                    data: 'type',
483
                    data: "type",
487
                    sortable: false,
484
                    sortable: false,
488
                    render: (data, type, row, meta) => {
485
                    render: (data, type, row, meta) => {
489
                        return display_extended_attribute(row, 'type');
486
                        return display_extended_attribute(row, "type");
490
                    },
487
                    },
491
                },
488
                },
492
                {
489
                {
493
                    data: 'status',
490
                    data: "status",
494
                    sortable: true,
491
                    sortable: true,
495
                    render: (data, type, row, meta) => {
492
                    render: (data, type, row, meta) => {
496
                        return display_request_status(row);
493
                        return display_request_status(row);
497
                    },
494
                    },
498
                },
495
                },
499
                {
496
                {
500
                    data: 'requested_date',
497
                    data: "requested_date",
501
                    sortable: true,
498
                    sortable: true,
502
                    render: (data, type, row, meta) => {
499
                    render: (data, type, row, meta) => {
503
                        return $date(data);
500
                        return $date(data);
504
                    },
501
                    },
505
                },
502
                },
506
                {
503
                {
507
                    data: 'timestamp',
504
                    data: "timestamp",
508
                    sortable: true,
505
                    sortable: true,
509
                    render: (data, type, row, meta) => {
506
                    render: (data, type, row, meta) => {
510
                        return $date(data);
507
                        return $date(data);
511
                    },
508
                    },
512
                },
509
                },
513
                {
510
                {
514
                    data: '',
511
                    data: "",
515
                    sortable: false,
512
                    sortable: false,
516
                    render: (data, type, row, meta) => {
513
                    render: (data, type, row, meta) => {
517
                        return `<a href="/cgi-bin/koha/opac-illrequests.pl?op=view&amp;illrequest_id=${row.ill_request_id}" class="btn btn-primary btn-sm">View</a>`;
514
                        return `<a href="/cgi-bin/koha/opac-illrequests.pl?op=view&amp;illrequest_id=${row.ill_request_id}" class="btn btn-primary btn-sm">View</a>`;
518
                    },
515
                    },
519
                }
516
                },
520
            ]
517
            ],
521
        });
518
        });
522
        $("#backend-dropdown-options").removeClass("nojs");
519
        $("#backend-dropdown-options").removeClass("nojs");
523
    </script>
520
    </script>
(-)a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-messaging.tt (-24 / +26 lines)
Lines 368-423 Link Here
368
            OPACTableColExpandedByDefault: [% Koha.Preference('OPACTableColExpandedByDefault') ? 1 : 0 | html %],
368
            OPACTableColExpandedByDefault: [% Koha.Preference('OPACTableColExpandedByDefault') ? 1 : 0 | html %],
369
        });
369
        });
370
    </script>
370
    </script>
371
372
    <script>
371
    <script>
373
        $(document).ready(function(){
372
        $(document).ready(function () {
374
            function toggle_digest(id){
373
            function toggle_digest(id) {
375
                let phone_checked = prefs.TalkingTechItivaPhoneNotification ? false : prefs.PhoneNotification ? $("#phone"+id).prop("checked") : false;
374
                let phone_checked = prefs.TalkingTechItivaPhoneNotification ? false : prefs.PhoneNotification ? $("#phone" + id).prop("checked") : false;
376
375
377
                if ( $("#email"+id).prop("checked") || $("#sms"+id).prop("checked") || phone_checked ) {
376
                if ($("#email" + id).prop("checked") || $("#sms" + id).prop("checked") || phone_checked) {
378
                    $("#digest"+id).attr("disabled", false).tooltip('disable');
377
                    $("#digest" + id)
378
                        .attr("disabled", false)
379
                        .tooltip("disable");
379
                } else {
380
                } else {
380
                    $("#digest"+id).attr("disabled", true).prop("checked",false).tooltip('enable');
381
                    $("#digest" + id)
382
                        .attr("disabled", true)
383
                        .prop("checked", false)
384
                        .tooltip("enable");
381
                }
385
                }
382
383
            }
386
            }
384
            // At load time, we want digest disabled if no digest using transport is enabled
387
            // At load time, we want digest disabled if no digest using transport is enabled
385
            $(".pmp_email").each(function(){
388
            $(".pmp_email").each(function () {
386
                toggle_digest(Number($(this).attr("id").replace("email", "")));
389
                toggle_digest(Number($(this).attr("id").replace("email", "")));
387
            });
390
            });
388
391
389
            // If user clears all digest using transports for a notice, disable digest checkbox
392
            // If user clears all digest using transports for a notice, disable digest checkbox
390
            $(".pmp_email").click(function(){
393
            $(".pmp_email").click(function () {
391
                toggle_digest(Number($(this).attr("id").replace("email", "")));
394
                toggle_digest(Number($(this).attr("id").replace("email", "")));
392
            });
395
            });
393
            $(".pmp_sms").click(function(){
396
            $(".pmp_sms").click(function () {
394
                toggle_digest(Number($(this).attr("id").replace("sms", "")));
397
                toggle_digest(Number($(this).attr("id").replace("sms", "")));
395
            });
398
            });
396
            $(".pmp_phone").click(function(){
399
            $(".pmp_phone").click(function () {
397
                toggle_digest(Number($(this).attr("id").replace("phone", "")));
400
                toggle_digest(Number($(this).attr("id").replace("phone", "")));
398
            });
401
            });
399
400
        });
402
        });
401
403
402
        function normalizeSMS(value){
404
        function normalizeSMS(value) {
403
            let has_plus = value.charAt(0) === '+';
405
            let has_plus = value.charAt(0) === "+";
404
            let new_value = value.replace(/\D/g,'');
406
            let new_value = value.replace(/\D/g, "");
405
            if ( has_plus ) new_value = '+' + new_value;
407
            if (has_plus) new_value = "+" + new_value;
406
            return new_value;
408
            return new_value;
407
        }
409
        }
408
410
409
        var sms_input = document.getElementById('SMSnumber');
411
        var sms_input = document.getElementById("SMSnumber");
410
412
411
        if (typeof sms_input !== 'undefined' && sms_input !== null) {
413
        if (typeof sms_input !== "undefined" && sms_input !== null) {
412
            sms_input.addEventListener('keyup', function(){
414
            sms_input.addEventListener("keyup", function () {
413
                var field = sms_input.value;
415
                var field = sms_input.value;
414
                sms_input.value = normalizeSMS(field);
416
                sms_input.value = normalizeSMS(field);
415
            });
417
            });
416
418
417
            sms_input.addEventListener('paste', function(event) {
419
            sms_input.addEventListener("paste", function (event) {
418
                let paste = (event.clipboardData || window.clipboardData).getData('text');
420
                let paste = (event.clipboardData || window.clipboardData).getData("text");
419
                setTimeout(function () {
421
                setTimeout(function () {
420
                sms_input.value = normalizeSMS(paste);
422
                    sms_input.value = normalizeSMS(paste);
421
                }, 100);
423
                }, 100);
422
            });
424
            });
423
        }
425
        }
Lines 431-437 Link Here
431
                details: {
433
                details: {
432
                    display: responsive_display,
434
                    display: responsive_display,
433
                    type: "column",
435
                    type: "column",
434
                    target: -1
436
                    target: -1,
435
                },
437
                },
436
            },
438
            },
437
            columnDefs: [{ className: "dtr-control", orderable: false, targets: -1 }],
439
            columnDefs: [{ className: "dtr-control", orderable: false, targets: -1 }],
(-)a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-readingrecord.tt (-25 / +22 lines)
Lines 234-279 Link Here
234
            OPACTableColExpandedByDefault: [% Koha.Preference('OPACTableColExpandedByDefault') ? 1 : 0 | html %],
234
            OPACTableColExpandedByDefault: [% Koha.Preference('OPACTableColExpandedByDefault') ? 1 : 0 | html %],
235
        });
235
        });
236
    </script>
236
    </script>
237
238
    <script>
237
    <script>
239
        $(document).ready(function(){
238
        $(document).ready(function () {
240
            if ( prefs.GoogleJackets ){
239
            if (prefs.GoogleJackets) {
241
                KOHA.Google.GetCoverFromIsbn();
240
                KOHA.Google.GetCoverFromIsbn();
242
            }
241
            }
243
            $('#order').change(function() {
242
            $("#order").change(function () {
244
                $('#sortform').submit();
243
                $("#sortform").submit();
245
            });
244
            });
246
245
247
            var responsive_display = prefs.OPACTableColExpandedByDefault ? DataTable.Responsive.display.childRowImmediate : DataTable.Responsive.display.childRow;
246
            var responsive_display = prefs.OPACTableColExpandedByDefault ? DataTable.Responsive.display.childRowImmediate : DataTable.Responsive.display.childRow;
248
            var table = $("#readingrec").kohaTable(
247
            var table = $("#readingrec").kohaTable({
249
                {
248
                dom: '<"top"<"table_entries"i><"table_controls"fB>>t',
250
                    dom: '<"top"<"table_entries"i><"table_controls"fB>>t',
249
                language: {
251
                    language: {
250
                    search: "_INPUT_",
252
                        search: "_INPUT_",
251
                    searchPlaceholder: _("Search"),
253
                        searchPlaceholder: _("Search"),
252
                },
254
                    },
253
                responsive: {
255
                    responsive: {
254
                    details: {
256
                        details: {
255
                        display: responsive_display,
257
                            display: responsive_display,
256
                        type: "column",
258
                            type: "column",
257
                        target: -1,
259
                            target: -1
260
                        },
261
                    },
258
                    },
262
                    columnDefs: [
263
                        { className: "dtr-control", orderable: false, targets: [-1] },
264
                        { visible: false, targets: [0] },
265
                    ],
266
                },
259
                },
267
            );
260
                columnDefs: [
261
                    { className: "dtr-control", orderable: false, targets: [-1] },
262
                    { visible: false, targets: [0] },
263
                ],
264
            });
268
265
269
            let table_dt = table.DataTable();
266
            let table_dt = table.DataTable();
270
267
271
            $("#tabs a[data-bs-toggle='tab']").on("shown.bs.tab", function (e) {
268
            $("#tabs a[data-bs-toggle='tab']").on("shown.bs.tab", function (e) {
272
                var id = e.target.id;
269
                var id = e.target.id;
273
                let pattern = "";
270
                let pattern = "";
274
                if ( id == "checkout-tab" ) {
271
                if (id == "checkout-tab") {
275
                    pattern = "standard_checkout";
272
                    pattern = "standard_checkout";
276
                } else if ( id == "onsite_checkout-tab" ) {
273
                } else if (id == "onsite_checkout-tab") {
277
                    pattern = "onsite_checkout";
274
                    pattern = "onsite_checkout";
278
                }
275
                }
279
                table_dt.columns(0).search(pattern).draw();
276
                table_dt.columns(0).search(pattern).draw();
(-)a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-suggestions.tt (-78 / +74 lines)
Lines 579-596 Link Here
579
    <script>
579
    <script>
580
        const loggedinusername = [% ( loggedinusername ) ? 1 : 0 | html %];
580
        const loggedinusername = [% ( loggedinusername ) ? 1 : 0 | html %];
581
    </script>
581
    </script>
582
583
    [% IF ( loggedinusername ) %]
582
    [% IF ( loggedinusername ) %]
584
        <script>
583
        <script>
585
            function enableCheckboxActions(){
584
            function enableCheckboxActions() {
586
                // Enable/disable controls if checkboxes are checked
585
                // Enable/disable controls if checkboxes are checked
587
                var checkedBoxes = $(".cb:checked");
586
                var checkedBoxes = $(".cb:checked");
588
                if ($(checkedBoxes).size()) {
587
                if ($(checkedBoxes).size()) {
589
                  $(".selections").html(_("With selected suggestions: "));
588
                    $(".selections").html(_("With selected suggestions: "));
590
                  $(".selections-toolbar .links a").removeClass("disabled");
589
                    $(".selections-toolbar .links a").removeClass("disabled");
591
                } else {
590
                } else {
592
                  $(".selections").html(_("Select suggestions to: "));
591
                    $(".selections").html(_("Select suggestions to: "));
593
                  $(".selections-toolbar .links a").addClass("disabled");
592
                    $(".selections-toolbar .links a").addClass("disabled");
594
                }
593
                }
595
            }
594
            }
596
        </script>
595
        </script>
Lines 598-689 Link Here
598
597
599
    [% IF Koha.Preference( 'OPACSuggestionAutoFill' ) %]
598
    [% IF Koha.Preference( 'OPACSuggestionAutoFill' ) %]
600
        <script>
599
        <script>
601
        $(function() {
600
            $(function () {
602
            $('#isbn').autofill({
601
                $("#isbn").autofill({
603
                'volumeInfo.title': {target: 'title', effect: 'flash'},
602
                    "volumeInfo.title": { target: "title", effect: "flash" },
604
                'volumeInfo.authors': {target: 'author', effect: 'flash'},
603
                    "volumeInfo.authors": { target: "author", effect: "flash" },
605
                'volumeInfo.publisher': {target: 'publishercode', effect: 'flash'},
604
                    "volumeInfo.publisher": { target: "publishercode", effect: "flash" },
606
                'volumeInfo.publishedDate': {target: 'copyrightdate', effect: 'flash'},
605
                    "volumeInfo.publishedDate": { target: "copyrightdate", effect: "flash" },
607
                /* google books api seem to only have books, so if we got a result
606
                    /* google books api seem to only have books, so if we got a result
608
                 * item, type will be a book, so set to BK (book). */
607
                     * item, type will be a book, so set to BK (book). */
609
                'kind': {target: 'itemtype', handle: function(t,v) { t.val('BK'); },},
608
                    kind: {
609
                        target: "itemtype",
610
                        handle: function (t, v) {
611
                            t.val("BK");
612
                        },
613
                    },
614
                });
610
            });
615
            });
611
        });
612
        </script>
616
        </script>
613
    [% END %]
617
    [% END %]
614
615
    <script>
618
    <script>
616
        $(function() {
619
        $(function () {
617
            $("#suggestt").kohaTable({
620
            $("#suggestt").kohaTable({
618
                order: [[ 1, "asc" ]],
621
                order: [[1, "asc"]],
619
                columnDefs: [
622
                columnDefs: [...(loggedinusername ? [{ targets: [0], orderable: false, searchable: false }] : []), { className: "dtr-control", orderable: false, targets: -1 }, { responsivePriority: 1, targets: 1 }],
620
                    ...( loggedinusername
621
                        ? [{ targets: [ 0 ], orderable: false, searchable: false }]
622
                        : []
623
                    ),
624
                    { className: 'dtr-control', orderable: false, targets: -1 },
625
                    { responsivePriority: 1, targets: 1 }
626
                ],
627
                responsive: {
623
                responsive: {
628
                    details: {
624
                    details: {
629
                        type: 'column',
625
                        type: "column",
630
                        target: -1
626
                        target: -1,
631
                    }
627
                    },
632
                },
628
                },
633
            });
629
            });
634
            if (loggedinusername){
630
            if (loggedinusername) {
635
            $("span.clearall").html("<a id=\"CheckNone\" class=\"btn btn-link btn-sm\" href=\"#\">"+_("Clear all")+"<\/a>");
631
                $("span.clearall").html('<a id="CheckNone" class="btn btn-link btn-sm" href="#">' + _("Clear all") + "<\/a>");
636
            $("span.checkall").html("<a id=\"CheckAll\" class=\"btn btn-link btn-sm\" href=\"#\">"+_("Select all")+"<\/a>");
632
                $("span.checkall").html('<a id="CheckAll" class="btn btn-link btn-sm" href="#">' + _("Select all") + "<\/a>");
637
            $("#CheckAll").on("click",function(e){
633
                $("#CheckAll").on("click", function (e) {
638
                e.preventDefault();
634
                    e.preventDefault();
639
                $(".cb").prop("checked", true);
635
                    $(".cb").prop("checked", true);
640
                enableCheckboxActions();
636
                    enableCheckboxActions();
641
            });
637
                });
642
            $("#CheckNone").on("click",function(e){
638
                $("#CheckNone").on("click", function (e) {
643
                e.preventDefault();
639
                    e.preventDefault();
644
                $(".cb").prop("checked", false);
640
                    $(".cb").prop("checked", false);
645
                enableCheckboxActions();
641
                    enableCheckboxActions();
646
            });
642
                });
647
            $(".cb").click(function(){
643
                $(".cb").click(function () {
648
              enableCheckboxActions();
644
                    enableCheckboxActions();
649
            });
645
                });
650
646
651
            enableCheckboxActions();
647
                enableCheckboxActions();
652
648
653
            $(".removeitems").on("click", function(e) {
649
                $(".removeitems").on("click", function (e) {
654
                e.preventDefault();
650
                    e.preventDefault();
655
                var selected_titles = $("input:checked");
651
                    var selected_titles = $("input:checked");
656
                var title;
652
                    var title;
657
                var yes_label;
653
                    var yes_label;
658
                var no_label;
654
                    var no_label;
659
                var message = "";
655
                    var message = "";
660
                if ( selected_titles.size() < 1 ) {
656
                    if (selected_titles.size() < 1) {
661
                    alert( _("No suggestion was selected") );
657
                        alert(_("No suggestion was selected"));
662
                    return false;
658
                        return false;
663
                } else {
664
                    if( selected_titles.size() > 1 ){
665
                        message = $("<ul></ul>");
666
                        title = _("Are you sure you want to delete these suggestions?");
667
                        yes_label = _("Yes, delete suggestions");
668
                        no_label = _("No, do not delete suggestions");
669
                        selected_titles.each(function(){
670
                            message.append( "<li>" +  $(this).data("title") + "</li>" );
671
                        });
672
                    } else {
659
                    } else {
673
                        title = _("Are you sure you want to delete this suggestion?");
660
                        if (selected_titles.size() > 1) {
674
                        yes_label = _("Yes, delete suggestion");
661
                            message = $("<ul></ul>");
675
                        no_label = _("No, do not delete suggestion");
662
                            title = _("Are you sure you want to delete these suggestions?");
676
                        selected_titles.each(function(){
663
                            yes_label = _("Yes, delete suggestions");
677
                            message += $(this).data("title");
664
                            no_label = _("No, do not delete suggestions");
665
                            selected_titles.each(function () {
666
                                message.append("<li>" + $(this).data("title") + "</li>");
667
                            });
668
                        } else {
669
                            title = _("Are you sure you want to delete this suggestion?");
670
                            yes_label = _("Yes, delete suggestion");
671
                            no_label = _("No, do not delete suggestion");
672
                            selected_titles.each(function () {
673
                                message += $(this).data("title");
674
                            });
675
                        }
676
                        confirmModal(message, title, yes_label, no_label, function (result) {
677
                            if (result) {
678
                                $("#delete_suggestions").submit();
679
                            }
678
                        });
680
                        });
679
                    }
681
                    }
680
                    confirmModal( message, title, yes_label, no_label, function( result ){
682
                });
681
                        if( result ){
682
                            $("#delete_suggestions").submit();
683
                        }
684
                    });
685
                }
686
            });
687
            }
683
            }
688
        });
684
        });
689
    </script>
685
    </script>
(-)a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-user.tt (-193 / +194 lines)
Lines 1070-1248 Link Here
1070
        const is_debarred = [% userdebarred ? 1 : 0 | html %];
1070
        const is_debarred = [% userdebarred ? 1 : 0 | html %];
1071
        const current_article_requests_size = [% current_article_requests.size || 0 | html %];
1071
        const current_article_requests_size = [% current_article_requests.size || 0 | html %];
1072
    </script>
1072
    </script>
1073
1074
    <script>
1073
    <script>
1075
        var AR_CAPTION_COUNT = _("(%s total)");
1074
        var AR_CAPTION_COUNT = _("(%s total)");
1076
1075
1077
1076
        function tableInit(tableId) {
1078
        function tableInit( tableId ){
1077
            if (tableId == "checkoutst") {
1079
            if( tableId == "checkoutst" ){
1078
                $(".dt-buttons").append('<button type="button" class="dt-button buttons-ical" id="buttons-ics">iCal</button> ');
1080
                $(".dt-buttons").append("<button type=\"button\" class=\"dt-button buttons-ical\" id=\"buttons-ics\">iCal</button> ");
1079
                if (prefs.OpacRenewalAllowed && can_renew && !is_debarred) {
1081
                if (prefs.OpacRenewalAllowed && can_renew && !is_debarred){
1080
                    $(".dt-buttons").append(
1082
                    $(".dt-buttons").append("<button id=\"renewselected_link\" class=\"dt-button buttons-renew\"><i class=\"fa fa-check\" aria-hidden=\"true\"></i> "+_("Renew selected")+"</button> <button id=\"renewall_link\" class=\"dt-button buttons-renewall\"><span class=\"fa-stack\"><i class=\"fa fa-check fa-stack-1x\" aria-hidden=\"true\"></i><i class=\"fa fa-check fa-stack-1x\" aria-hidden=\"true\"></i></span> "+_("Renew all")+"</button>");
1081
                        '<button id="renewselected_link" class="dt-button buttons-renew"><i class="fa fa-check" aria-hidden="true"></i> ' +
1082
                            _("Renew selected") +
1083
                            '</button> <button id="renewall_link" class="dt-button buttons-renewall"><span class="fa-stack"><i class="fa fa-check fa-stack-1x" aria-hidden="true"></i><i class="fa fa-check fa-stack-1x" aria-hidden="true"></i></span> ' +
1084
                            _("Renew all") +
1085
                            "</button>"
1086
                    );
1083
                }
1087
                }
1084
            }
1088
            }
1085
        }
1089
        }
1086
        $(document).ready(function(){
1090
        $(document).ready(function () {
1087
            if (tab){
1091
            if (tab) {
1088
                $(`#opac-user-views a[href='#${tab}_panel']`).tab("show");
1092
                $(`#opac-user-views a[href='#${tab}_panel']`).tab("show");
1089
            }
1093
            }
1090
            if( $("#opac-user-views .tab-pane.active").length < 1 ){
1094
            if ($("#opac-user-views .tab-pane.active").length < 1) {
1091
                $("#opac-user-views a:first").tab("show");
1095
                $("#opac-user-views a:first").tab("show");
1092
            }
1096
            }
1093
1097
1094
            $('#article-requests-table caption .count').html(AR_CAPTION_COUNT.format(current_article_requests_size));
1098
            $("#article-requests-table caption .count").html(AR_CAPTION_COUNT.format(current_article_requests_size));
1095
1099
1096
            $(".modal-nojs").addClass("modal").addClass("hide").removeClass("modal-nojs");
1100
            $(".modal-nojs").addClass("modal").addClass("hide").removeClass("modal-nojs");
1097
1101
1098
            $(".btn-delete-hold").on("click", function(e){
1102
            $(".btn-delete-hold").on("click", function (e) {
1099
                e.preventDefault();
1103
                e.preventDefault();
1100
                var hold_title = $(this).data("title");
1104
                var hold_title = $(this).data("title");
1101
                var reserve_id = $(this).data("reserve_id");
1105
                var reserve_id = $(this).data("reserve_id");
1102
                confirmModal( hold_title, _("Are you sure you want to cancel this hold?"), _("Yes, cancel hold"), _("No, do not cancel hold"), function( result ){
1106
                confirmModal(hold_title, _("Are you sure you want to cancel this hold?"), _("Yes, cancel hold"), _("No, do not cancel hold"), function (result) {
1103
                        if( result ){
1107
                    if (result) {
1104
                            $("#delete_hold_" + reserve_id ).submit();
1108
                        $("#delete_hold_" + reserve_id).submit();
1105
                        }
1106
                    }
1109
                    }
1107
                );
1110
                });
1108
            });
1111
            });
1109
1112
1110
            $(".btn-req-delete-hold").on("click", function(e){
1113
            $(".btn-req-delete-hold").on("click", function (e) {
1111
                e.preventDefault();
1114
                e.preventDefault();
1112
                var hold_title = $(this).data("title");
1115
                var hold_title = $(this).data("title");
1113
                var reserve_id = $(this).data("reserve_id");
1116
                var reserve_id = $(this).data("reserve_id");
1114
                confirmModal( hold_title, _("Are you sure you want to request cancelling this hold?"), _("Yes"), _("No"), function( result ){
1117
                confirmModal(hold_title, _("Are you sure you want to request cancelling this hold?"), _("Yes"), _("No"), function (result) {
1115
                        if( result ){
1118
                    if (result) {
1116
                            $("#req_cancel_hold_" + reserve_id ).submit();
1119
                        $("#req_cancel_hold_" + reserve_id).submit();
1117
                        }
1118
                    }
1120
                    }
1119
                );
1121
                });
1120
            });
1122
            });
1121
1123
1122
            $("#article-requests-table").on("click", ".btn-delete-article-request", function(e){
1124
            $("#article-requests-table").on("click", ".btn-delete-article-request", function (e) {
1123
                e.preventDefault();
1125
                e.preventDefault();
1124
                var article_request = $(this).data("title");
1126
                var article_request = $(this).data("title");
1125
                var article_request_id = $(this).data("article-request_id");
1127
                var article_request_id = $(this).data("article-request_id");
1126
                (function(row){
1128
                (function (row) {
1127
                    var doCancel = function( result ){
1129
                    var doCancel = function (result) {
1128
                        if( result ){
1130
                        if (result) {
1129
                            $.ajax({
1131
                            $.ajax({
1130
                                type: "DELETE",
1132
                                type: "DELETE",
1131
                                url: `/api/v1/public/patrons/${logged_in_user_borrowernumber}/article_requests/${article_request_id}?cancellation_reason=OPAC`,
1133
                                url: `/api/v1/public/patrons/${logged_in_user_borrowernumber}/article_requests/${article_request_id}?cancellation_reason=OPAC`,
1132
                                success: function( data ) {
1134
                                success: function (data) {
1133
                                    $("#article_" + article_request_id ).hide({
1135
                                    $("#article_" + article_request_id).hide({
1134
                                        duration: 'slow',
1136
                                        duration: "slow",
1135
                                        complete: function() {
1137
                                        complete: function () {
1136
                                            $(this).siblings(".child").hide();
1138
                                            $(this).siblings(".child").hide();
1137
                                            var ar_tab = $('a[href="#opac-user-article-requests_panel"');
1139
                                            var ar_tab = $('a[href="#opac-user-article-requests_panel"');
1138
                                            var ar_table = $('#article-requests-table');
1140
                                            var ar_table = $("#article-requests-table");
1139
                                            var ar_length = $('tbody tr:visible', ar_table).length;
1141
                                            var ar_length = $("tbody tr:visible", ar_table).length;
1140
                                            var ar_count = $('caption .count', ar_table);
1142
                                            var ar_count = $("caption .count", ar_table);
1141
1143
1142
                                            ar_tab.html(ar_tab.html().replace(/\(\d+\)/, '('+ar_length+')'));
1144
                                            ar_tab.html(ar_tab.html().replace(/\(\d+\)/, "(" + ar_length + ")"));
1143
                                            ar_count.html(AR_CAPTION_COUNT.format(ar_length));
1145
                                            ar_count.html(AR_CAPTION_COUNT.format(ar_length));
1144
1146
                                        },
1145
                                        }
1146
                                    });
1147
                                    });
1147
                                }
1148
                                },
1148
                            });
1149
                            });
1149
                        }
1150
                        }
1150
                    };
1151
                    };
1151
                    confirmModal( article_request, _("Are you sure you want to cancel this article request?"), _("Yes, cancel article request"), _("No, do not cancel article request"), doCancel);
1152
                    confirmModal(article_request, _("Are you sure you want to cancel this article request?"), _("Yes, cancel article request"), _("No, do not cancel article request"), doCancel);
1152
                })($(this))
1153
                })($(this));
1153
            });
1154
            });
1154
1155
1155
            /* We initiate this flatpickr instance here so that we can use the variable later */
1156
            /* We initiate this flatpickr instance here so that we can use the variable later */
1156
            var suspend_until_date = $("#suspend_untilDate").flatpickr({
1157
            var suspend_until_date = $("#suspend_untilDate").flatpickr({
1157
                minDate: "today"
1158
                minDate: "today",
1158
            });
1159
            });
1159
1160
1160
            $(document).on("click", ".suspend_hold", function(e){
1161
            $(document).on("click", ".suspend_hold", function (e) {
1161
                e.preventDefault();
1162
                e.preventDefault();
1162
                var title = $(this).data("title");
1163
                var title = $(this).data("title");
1163
                var reserve_id = $(this).data("reserve_id");
1164
                var reserve_id = $(this).data("reserve_id");
1164
                $("#suspendHoldReserveId").val( reserve_id );
1165
                $("#suspendHoldReserveId").val(reserve_id);
1165
                $("#suspendHoldTitle").html( "<em>" + title + "</em>" );
1166
                $("#suspendHoldTitle").html("<em>" + title + "</em>");
1166
                $("#suspendHoldModal").modal("show");
1167
                $("#suspendHoldModal").modal("show");
1167
            });
1168
            });
1168
1169
1169
            $("#suspendHoldModal").on("hidden.bs.modal", function(){
1170
            $("#suspendHoldModal").on("hidden.bs.modal", function () {
1170
                $("#suspendHoldTitle").html("");
1171
                $("#suspendHoldTitle").html("");
1171
                $("#suspendHoldReserveId").val("");
1172
                $("#suspendHoldReserveId").val("");
1172
                suspend_until_date.clear();
1173
                suspend_until_date.clear();
1173
            });
1174
            });
1174
1175
1175
            $("#suspend_all_submit").on("click", function(e){
1176
            $("#suspend_all_submit").on("click", function (e) {
1176
                e.preventDefault();
1177
                e.preventDefault();
1177
                var title = _("Are you sure you want to suspend all holds?");
1178
                var title = _("Are you sure you want to suspend all holds?");
1178
                var body = _("All holds will be suspended.");
1179
                var body = _("All holds will be suspended.");
1179
                confirmModal( body, title, _("Yes, suspend all holds"), "", function( result ){
1180
                confirmModal(body, title, _("Yes, suspend all holds"), "", function (result) {
1180
                        if( result ){
1181
                    if (result) {
1181
                            $("#suspend_all_holds").submit();
1182
                        $("#suspend_all_holds").submit();
1182
                        }
1183
                    }
1183
                    }
1184
                );
1184
                });
1185
            });
1185
            });
1186
1186
1187
            $("#resume_all_submit").on("click", function(e){
1187
            $("#resume_all_submit").on("click", function (e) {
1188
                e.preventDefault();
1188
                e.preventDefault();
1189
                var title = _("Are you sure you want to resume all suspended holds?");
1189
                var title = _("Are you sure you want to resume all suspended holds?");
1190
                var body = _("All holds will resume.");
1190
                var body = _("All holds will resume.");
1191
                confirmModal( body, title, _("Yes, resume all holds"), _("No, do not resume holds"), function( result ){
1191
                confirmModal(body, title, _("Yes, resume all holds"), _("No, do not resume holds"), function (result) {
1192
                        if( result ){
1192
                    if (result) {
1193
                            $("#resume_all_holds").submit();
1193
                        $("#resume_all_holds").submit();
1194
                        }
1195
                    }
1194
                    }
1196
                );
1195
                });
1197
            });
1196
            });
1198
1197
1199
            var dTables = $("#checkoutst,#holdst,#overduest,#opac-user-relative-issues-table");
1198
            var dTables = $("#checkoutst,#holdst,#overduest,#opac-user-relative-issues-table");
1200
            dTables.each(function(){
1199
            dTables.each(function () {
1201
                var thIndex = $(this).find("th.psort").index();
1200
                var thIndex = $(this).find("th.psort").index();
1202
                $(this).on("init.dt", function() {
1201
                $(this)
1203
                        tableInit( $(this).attr("id") );
1202
                    .on("init.dt", function () {
1203
                        tableInit($(this).attr("id"));
1204
                    })
1204
                    })
1205
                    .kohaTable({
1205
                    .kohaTable({
1206
                    order: [[ thIndex, 'asc' ]],
1206
                        order: [[thIndex, "asc"]],
1207
                    dom: '<"top"<"table_entries"><"table_controls"fB>>t',
1207
                        dom: '<"top"<"table_entries"><"table_controls"fB>>t',
1208
                    columnDefs: [
1208
                        columnDefs: [
1209
                        { visible: false, "targets" : [ "hidden" ] },
1209
                            { visible: false, targets: ["hidden"] },
1210
                        { className: 'dtr-control', orderable: false, targets: -1 }
1210
                            { className: "dtr-control", orderable: false, targets: -1 },
1211
                    ],
1211
                        ],
1212
                    language: {
1212
                        language: {
1213
                        search: "_INPUT_",
1213
                            search: "_INPUT_",
1214
                        searchPlaceholder: _("Search")
1214
                            searchPlaceholder: _("Search"),
1215
                    },
1216
                    responsive: {
1217
                        details: {
1218
                            type: 'column',
1219
                            target: -1
1220
                        }
1221
                    },
1222
                    buttons: [
1223
                        /* Override default button set so that we can extend the options of print and csv */
1224
                        'clearFilter', 'copy',
1225
                        {
1226
                            extend: "print",
1227
                            exportOptions: {
1228
                                /* Print view should show all columns (even invisible ones) unless they are .no-export */
1229
                                columns: ":not(.no-export)"
1230
                            }
1231
                        },
1215
                        },
1232
                        {
1216
                        responsive: {
1233
                            extend: "csv",
1217
                            details: {
1234
                            exportOptions: {
1218
                                type: "column",
1235
                                /* CSV export should include all columns (even invisible ones) unless they are .no-export */
1219
                                target: -1,
1236
                                columns: ":not(.no-export)"
1220
                            },
1237
                            }
1221
                        },
1238
                        }
1222
                        buttons: [
1239
                    ]
1223
                            /* Override default button set so that we can extend the options of print and csv */
1240
                });
1224
                            "clearFilter",
1225
                            "copy",
1226
                            {
1227
                                extend: "print",
1228
                                exportOptions: {
1229
                                    /* Print view should show all columns (even invisible ones) unless they are .no-export */
1230
                                    columns: ":not(.no-export)",
1231
                                },
1232
                            },
1233
                            {
1234
                                extend: "csv",
1235
                                exportOptions: {
1236
                                    /* CSV export should include all columns (even invisible ones) unless they are .no-export */
1237
                                    columns: ":not(.no-export)",
1238
                                },
1239
                            },
1240
                        ],
1241
                    });
1241
            });
1242
            });
1242
1243
1243
            var responsive_display = prefs.OPACTableColExpandedByDefault ? DataTable.Responsive.display.childRowImmediate : DataTable.Responsive.display.childRow;
1244
            var responsive_display = prefs.OPACTableColExpandedByDefault ? DataTable.Responsive.display.childRowImmediate : DataTable.Responsive.display.childRow;
1244
            var dataTables = $("#recalls-table,#article-requests-table");
1245
            var dataTables = $("#recalls-table,#article-requests-table");
1245
            dataTables.each(function(){
1246
            dataTables.each(function () {
1246
                $(this).kohaTable({
1247
                $(this).kohaTable({
1247
                    searching: false,
1248
                    searching: false,
1248
                    paging: false,
1249
                    paging: false,
Lines 1251-1319 Link Here
1251
                        details: {
1252
                        details: {
1252
                            display: responsive_display,
1253
                            display: responsive_display,
1253
                            type: "column",
1254
                            type: "column",
1254
                            target: -1
1255
                            target: -1,
1255
                        },
1256
                        },
1256
                    },
1257
                    },
1257
                    columnDefs: [{ className: "dtr-control", orderable: false, targets: -1 }],
1258
                    columnDefs: [{ className: "dtr-control", orderable: false, targets: -1 }],
1258
                });
1259
                });
1259
            });
1260
            });
1260
            $('a[data-bs-toggle="tab"]').on('shown.bs.tab', function (event) {
1261
            $('a[data-bs-toggle="tab"]').on("shown.bs.tab", function (event) {
1261
                dTables.DataTable().responsive.recalc();
1262
                dTables.DataTable().responsive.recalc();
1262
                dataTables.DataTable().responsive.recalc();
1263
                dataTables.DataTable().responsive.recalc();
1263
            } );
1264
            });
1264
1265
1265
            $("body").on("click", "#buttons-ics", function(){
1266
            $("body").on("click", "#buttons-ics", function () {
1266
                location.href="/cgi-bin/koha/opac-ics.pl";
1267
                location.href = "/cgi-bin/koha/opac-ics.pl";
1267
            });
1268
            });
1268
1269
1269
            if (prefs.GoogleJackets){
1270
            if (prefs.GoogleJackets) {
1270
                KOHA.Google.GetCoverFromIsbn();
1271
                KOHA.Google.GetCoverFromIsbn();
1271
            }
1272
            }
1272
            if (prefs.OpacRenewalAllowed && can_renew && !is_debarred){
1273
            if (prefs.OpacRenewalAllowed && can_renew && !is_debarred) {
1273
                $("#renewselected").submit(function(){
1274
                $("#renewselected").submit(function () {
1274
                    valid = false;
1275
                    valid = false;
1275
                    $("input[type=checkbox]").each(function(){
1276
                    $("input[type=checkbox]").each(function () {
1276
                        if($(this).is(':checked')){
1277
                        if ($(this).is(":checked")) {
1277
                            valid = true;
1278
                            valid = true;
1278
                        }
1279
                        }
1279
                    });
1280
                    });
1280
                    if(!valid){
1281
                    if (!valid) {
1281
                        alert(_("Nothing has been selected. Check the box for each item you want to renew"));
1282
                        alert(_("Nothing has been selected. Check the box for each item you want to renew"));
1282
                    }
1283
                    }
1283
                    return valid;
1284
                    return valid;
1284
                });
1285
                });
1285
                $("body").on("click","#renewselected_link",function(e){
1286
                $("body").on("click", "#renewselected_link", function (e) {
1286
                    e.preventDefault();
1287
                    e.preventDefault();
1287
                    $("#renewselected").submit();
1288
                    $("#renewselected").submit();
1288
                });
1289
                });
1289
                $("body").on("click","#renewall_link, #renewall_js",function(e){
1290
                $("body").on("click", "#renewall_link, #renewall_js", function (e) {
1290
                    e.preventDefault();
1291
                    e.preventDefault();
1291
                    $("#renewall").submit();
1292
                    $("#renewall").submit();
1292
                });
1293
                });
1293
            }
1294
            }
1294
1295
1295
            if (prefs.AllowCheckoutNotes){
1296
            if (prefs.AllowCheckoutNotes) {
1296
1297
                /* If JS enabled, show button, otherwise show link to redirect to a page where note can be submitted */
1297
                /* If JS enabled, show button, otherwise show link to redirect to a page where note can be submitted */
1298
                $(".nonjs_submitnote").hide();
1298
                $(".nonjs_submitnote").hide();
1299
1299
1300
                $("input[name='note']").prop('readonly', false);
1300
                $("input[name='note']").prop("readonly", false);
1301
                $("input[name='note']").keypress(function(e){
1301
                $("input[name='note']").keypress(function (e) {
1302
                    /* prevent submitting of renewselected form */
1302
                    /* prevent submitting of renewselected form */
1303
                    if(e.which == 13)
1303
                    if (e.which == 13) e.preventDefault();
1304
                        e.preventDefault();
1305
                });
1304
                });
1306
1305
1307
                $("input[name='note']").keyup(function(e){
1306
                $("input[name='note']").keyup(function (e) {
1308
                    var $btn_save = $('#save_'+$(this).data('issue_id'));
1307
                    var $btn_save = $("#save_" + $(this).data("issue_id"));
1309
                    var origvalue = $(this).data('origvalue');
1308
                    var origvalue = $(this).data("origvalue");
1310
                    var value = $(this).val();
1309
                    var value = $(this).val();
1311
1310
1312
                    if(origvalue != value) {
1311
                    if (origvalue != value) {
1313
                        if(origvalue != "")
1312
                        if (origvalue != "") $btn_save.text(_("Submit changes"));
1314
                            $btn_save.text(_("Submit changes"));
1313
                        else $btn_save.text(_("Submit note"));
1315
                        else
1316
                            $btn_save.text(_("Submit note"));
1317
                        $btn_save.show();
1314
                        $btn_save.show();
1318
                    } else {
1315
                    } else {
1319
                        $btn_save.hide();
1316
                        $btn_save.hide();
Lines 1321-1440 Link Here
1321
                });
1318
                });
1322
            }
1319
            }
1323
1320
1324
            $(".change_pickup").on("click", function(){
1321
            $(".change_pickup").on("click", function () {
1325
                var hold_id = $(this).data("hold-id");
1322
                var hold_id = $(this).data("hold-id");
1326
                $(this).hide();
1323
                $(this).hide();
1327
                $("#change-pickup-location" + hold_id ).show();
1324
                $("#change-pickup-location" + hold_id).show();
1328
            });
1325
            });
1329
1326
1330
            if ( $('#opac-user-clubs_panel').length ) {
1327
            if ($("#opac-user-clubs_panel").length) {
1331
                $('#opac-user-clubs-tab').on('click', function() {
1328
                $("#opac-user-clubs-tab").on("click", function () {
1332
                    $('#opac-user-clubs_panel').text(_("Loading..."));
1329
                    $("#opac-user-clubs_panel").text(_("Loading..."));
1333
                    $('#opac-user-clubs_panel').load(`/cgi-bin/koha/clubs/clubs-tab.pl?borrowernumber=${logged_in_user_borrowernumber}`);
1330
                    $("#opac-user-clubs_panel").load(`/cgi-bin/koha/clubs/clubs-tab.pl?borrowernumber=${logged_in_user_borrowernumber}`);
1334
                });
1331
                });
1335
            }
1332
            }
1336
1333
1337
            $(".cancel_recall").click(function(e){
1334
            $(".cancel_recall").click(function (e) {
1338
                return confirmDelete(_("Are you sure you want to remove this recall?"));
1335
                return confirmDelete(_("Are you sure you want to remove this recall?"));
1339
            });
1336
            });
1340
1337
1341
            $("body").on("click", ".btn-add-note", function(e){
1338
            $("body").on("click", ".btn-add-note", function (e) {
1342
                e.preventDefault();
1339
                e.preventDefault();
1343
                var title = $(this).data("title");
1340
                var title = $(this).data("title");
1344
                var issue_id = $(this).data("issueid");
1341
                var issue_id = $(this).data("issueid");
1345
                var note = $("#note_" + issue_id ).val();
1342
                var note = $("#note_" + issue_id).val();
1346
                var origvalue = $("#note_" + issue_id ).data("origvalue");
1343
                var origvalue = $("#note_" + issue_id).data("origvalue");
1347
                $("#addNote").val( note );
1344
                $("#addNote").val(note);
1348
                $("#addNoteIssueId").val( issue_id );
1345
                $("#addNoteIssueId").val(issue_id);
1349
                $("#addNoteTitle").text( title );
1346
                $("#addNoteTitle").text(title);
1350
                $("#addNoteModal").modal("show");
1347
                $("#addNoteModal").modal("show");
1351
            });
1348
            });
1352
1349
1353
            $("#addNoteForm").on("submit", function(e){
1350
            $("#addNoteForm").on("submit", function (e) {
1354
                e.preventDefault();
1351
                e.preventDefault();
1355
                var title = $("#addNoteTitle").text();
1352
                var title = $("#addNoteTitle").text();
1356
                var issue_id = $("#addNoteIssueId").val();
1353
                var issue_id = $("#addNoteIssueId").val();
1357
                var note = $("#addNote").val();
1354
                var note = $("#addNote").val();
1358
                submitNote( title, issue_id, note );
1355
                submitNote(title, issue_id, note);
1359
            });
1356
            });
1360
1357
1361
            $("#addNoteModal").on("hidden.bs.modal", function(){
1358
            $("#addNoteModal").on("hidden.bs.modal", function () {
1362
                $("#addNoteTitle").text("");
1359
                $("#addNoteTitle").text("");
1363
                $("#addNote").val("");
1360
                $("#addNote").val("");
1364
            });
1361
            });
1365
1362
1366
            $(".dismiss-message-button").click(function(e){
1363
            $(".dismiss-message-button").click(function (e) {
1367
                return confirmDelete(_("Are you sure you want to dismiss this message?"));
1364
                return confirmDelete(_("Are you sure you want to dismiss this message?"));
1368
            });
1365
            });
1369
1370
        });
1366
        });
1371
1367
1372
        function submitNote( title, issue_id, note ){
1368
        function submitNote(title, issue_id, note) {
1373
            var self = $("#addNoteModal");
1369
            var self = $("#addNoteModal");
1374
            var notebutton = $("#save_" + issue_id );
1370
            var notebutton = $("#save_" + issue_id);
1375
            var noteinput = $("#note_" + issue_id );
1371
            var noteinput = $("#note_" + issue_id);
1376
1372
1377
            var ajaxData = {
1373
            var ajaxData = {
1378
                'action': 'issuenote',
1374
                action: "issuenote",
1379
                'issue_id': issue_id,
1375
                issue_id: issue_id,
1380
                'note': note,
1376
                note: note,
1381
                csrf_token: $('meta[name="csrf-token"]').attr('content'),
1377
                csrf_token: $('meta[name="csrf-token"]').attr("content"),
1382
                op: 'cud-add_note',
1378
                op: "cud-add_note",
1383
            };
1379
            };
1384
1380
1385
            $.ajax({
1381
            $.ajax({
1386
                url: '/cgi-bin/koha/svc/checkout_notes/',
1382
                url: "/cgi-bin/koha/svc/checkout_notes/",
1387
                type: 'POST',
1383
                type: "POST",
1388
                dataType: 'json',
1384
                dataType: "json",
1389
                data: ajaxData,
1385
                data: ajaxData,
1390
            })
1386
            })
1391
            .done(function(data) {
1387
                .done(function (data) {
1392
                var message = "";
1388
                    var message = "";
1393
                if(data.status == 'saved') {
1389
                    if (data.status == "saved") {
1394
                    $("#notesaved").removeClass("alert-error");
1390
                        $("#notesaved").removeClass("alert-error");
1395
                    $("#notesaved").addClass("alert-info");
1391
                        $("#notesaved").addClass("alert-info");
1396
                    noteinput.data('origvalue', data.note)
1392
                        noteinput.data("origvalue", data.note).val(data.note);
1397
                        .val(data.note);
1393
                        notebutton.text(_("Edit note"));
1398
                    notebutton.text( _("Edit note" ) );
1394
                        $("#viewnote_" + issue_id).text(data.note);
1399
                    $("#viewnote_" + issue_id ).text( data.note );
1395
                        message = "<p>" + _("Your note about %s has been saved and sent to the library.").format(em(title)) + "</p>";
1400
                    message = "<p>" + _("Your note about %s has been saved and sent to the library.").format( em(title) ) + "</p>";
1396
                        message += '<p class="checkout_note">' + data.note;
1401
                    message += "<p class=\"checkout_note\">" + data.note;
1397
                        message +=
1402
                    message += "<a href=\"/cgi-bin/koha/opac-issue-note.pl?issue_id=" + issue_id + "\" class=\"btn btn-link btn-sm btn-add-note\" data-title=\"" + title + "\" data-issueid=\"" + issue_id + "\"><i class=\"fa fa-pencil\" aria-hidden=\"true\"></i> " + _("Edit note") + "</a>";
1398
                            '<a href="/cgi-bin/koha/opac-issue-note.pl?issue_id=' +
1403
                    message += "</p>";
1399
                            issue_id +
1404
                } else if(data.status == 'removed') {
1400
                            '" class="btn btn-link btn-sm btn-add-note" data-title="' +
1405
                    $("#notesaved").removeClass("alert-error");
1401
                            title +
1406
                    $("#notesaved").addClass("alert-info");
1402
                            '" data-issueid="' +
1407
                    noteinput.data('origvalue', "")
1403
                            issue_id +
1408
                        .val("")
1404
                            '"><i class="fa fa-pencil" aria-hidden="true"></i> ' +
1409
                    notebutton.text( _("Add note") );
1405
                            _("Edit note") +
1410
                    $("#viewnote_" + issue_id ).text( data.note );
1406
                            "</a>";
1411
                    message = "<p>" + _("Your note about %s was removed.").format( em(title) ) + "</p>";
1407
                        message += "</p>";
1412
                } else {
1408
                    } else if (data.status == "removed") {
1409
                        $("#notesaved").removeClass("alert-error");
1410
                        $("#notesaved").addClass("alert-info");
1411
                        noteinput.data("origvalue", "").val("");
1412
                        notebutton.text(_("Add note"));
1413
                        $("#viewnote_" + issue_id).text(data.note);
1414
                        message = "<p>" + _("Your note about %s was removed.").format(em(title)) + "</p>";
1415
                    } else {
1416
                        $("#notesaved").removeClass("alert-info");
1417
                        $("#notesaved").addClass("alert-error");
1418
                        message = "<p>" + _("Your note about %s could not be saved.").format(em(title)) + "</p>";
1419
                        notebutton.text(_("Add note"));
1420
                        $("#viewnote_" + issue_id).text(data.note);
1421
                        message += '<p style="font-weight:bold;">' + _("Something went wrong. The note has not been saved") + "</p>";
1422
                    }
1423
                    $("#notesaved").html(message);
1424
                })
1425
                .fail(function (data) {
1413
                    $("#notesaved").removeClass("alert-info");
1426
                    $("#notesaved").removeClass("alert-info");
1414
                    $("#notesaved").addClass("alert-error");
1427
                    $("#notesaved").addClass("alert-error");
1415
                    message =  "<p>" + _("Your note about %s could not be saved.").format( em(title) ) + "</p>";
1428
                    var message = '<p style="font-weight:bold;">' + _("Something went wrong. The note has not been saved") + "</p>";
1416
                    notebutton.text( _("Add note") );
1429
                    $("#notesaved").html(message);
1417
                    $("#viewnote_" + issue_id ).text( data.note );
1430
                })
1418
                    message += "<p style=\"font-weight:bold;\">" + _("Something went wrong. The note has not been saved") + "</p>";
1431
                .always(function () {
1419
                }
1432
                    self.modal("hide");
1420
                $("#notesaved").html(message);
1433
                    $("#notesaved").show();
1421
            })
1434
                });
1422
            .fail(function(data) {
1423
                $("#notesaved").removeClass("alert-info");
1424
                $("#notesaved").addClass("alert-error");
1425
                var message = "<p style=\"font-weight:bold;\">" + _("Something went wrong. The note has not been saved") + "</p>";
1426
                $("#notesaved").html(message);
1427
            })
1428
            .always(function() {
1429
                self.modal("hide");
1430
                $("#notesaved").show();
1431
            });
1432
        }
1435
        }
1433
1436
1434
        function em( title ){
1437
        function em(title) {
1435
            return "<em>" + title + "</em>";
1438
            return "<em>" + title + "</em>";
1436
        }
1439
        }
1437
1438
    </script>
1440
    </script>
1439
    [% IF ( Koha.Preference('OpacStarRatings') == 'all' ) %]
1441
    [% IF ( Koha.Preference('OpacStarRatings') == 'all' ) %]
1440
        [% Asset.js("lib/jquery/plugins/jquery.barrating.min.js") | $raw %]
1442
        [% Asset.js("lib/jquery/plugins/jquery.barrating.min.js") | $raw %]
1441
- 

Return to bug 41582