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

(-)a/koha-tmpl/intranet-tmpl/prog/en/includes/patron-detail-tabs.inc (-15 / +3 lines)
Lines 182-202 Link Here
182
                    </form>
182
                    </form>
183
183
184
                    [% IF Koha.Preference('SuspendHoldsIntranet') %]
184
                    [% IF Koha.Preference('SuspendHoldsIntranet') %]
185
                        <form action="/cgi-bin/koha/reserve/modrequest_suspendall.pl" method="post">
185
                        <fieldset class="action">
186
                            [% INCLUDE 'csrf-token.inc' %]
186
                            <button class="btn btn-primary suspend_selected_holds" data-bulk="true"></button>
187
                            <fieldset class="action">
187
                        </fieldset>
188
                                <input type="hidden" name="op" value="cud-suspendall" />
189
                                <input type="hidden" name="from" value="[% patronpage | html %]" />
190
                                <input type="hidden" name="borrowernumber" value="[% patron.borrowernumber | html %]" />
191
                                <input type="submit" class="btn btn-primary" value="Suspend all holds" />
192
193
                                [% IF Koha.Preference('AutoResumeSuspendedHolds') %]
194
                                    <label for="suspend_until">until</label>
195
                                    <input type="text" size="10" id="suspend_until" name="suspend_until" class="flatpickr" data-flatpickr-futuredate="true" />
196
                                    <span class="hint">Specify date on which to resume [% INCLUDE 'date-format.inc' %]: </span>
197
                                [% END %]
198
                            </fieldset>
199
                        </form>
200
188
201
                        <form action="/cgi-bin/koha/reserve/modrequest_suspendall.pl" method="post">
189
                        <form action="/cgi-bin/koha/reserve/modrequest_suspendall.pl" method="post">
202
                            [% INCLUDE 'csrf-token.inc' %]
190
                            [% INCLUDE 'csrf-token.inc' %]
(-)a/koha-tmpl/intranet-tmpl/prog/js/holds.js (-31 / +62 lines)
Lines 107-122 function display_pickup_location(state) { Link Here
107
107
108
/* global __ borrowernumber SuspendHoldsIntranet */
108
/* global __ borrowernumber SuspendHoldsIntranet */
109
$(document).ready(function () {
109
$(document).ready(function () {
110
    function suspend_hold(hold_id, end_date) {
110
    var url = window.location.href;
111
        var params;
111
    let patron_page;
112
        if (end_date !== null && end_date !== "")
112
    if (url.indexOf("/circ/circulation.pl?borrowernumber=") !== -1)
113
            params = JSON.stringify({ end_date: end_date });
113
        patron_page = "circ";
114
    else if (url.indexOf("/members/moremember.pl?borrowernumber=") !== -1)
115
        patron_page = "borrower";
116
117
    function suspend_hold(hold_ids, end_date) {
118
        var params = { hold_ids: hold_ids };
119
        if (end_date !== null && end_date !== "") params.end_date = end_date;
114
120
115
        return $.ajax({
121
        return $.ajax({
116
            method: "POST",
122
            method: "POST",
117
            url: "/api/v1/holds/" + encodeURIComponent(hold_id) + "/suspension",
123
            url: "/api/v1/holds/suspension_bulk",
118
            contentType: "application/json",
124
            contentType: "application/json",
119
            data: params,
125
            data: JSON.stringify(params),
120
        });
126
        });
121
    }
127
    }
122
128
Lines 491-497 $(document).ready(function () { Link Here
491
                $(".hold-suspend").on("click", function () {
497
                $(".hold-suspend").on("click", function () {
492
                    var hold_id = $(this).data("hold-id");
498
                    var hold_id = $(this).data("hold-id");
493
                    var hold_title = $(this).data("hold-title");
499
                    var hold_title = $(this).data("hold-title");
494
                    $("#suspend-modal-title").html(hold_title);
500
                    $("#suspend-modal-title").html("<i>" + hold_title + "</i>");
495
                    $("#suspend-modal-submit").data("hold-id", hold_id);
501
                    $("#suspend-modal-submit").data("hold-id", hold_id);
496
                    $("#suspend-modal").modal("show");
502
                    $("#suspend-modal").modal("show");
497
                });
503
                });
Lines 585-591 $(document).ready(function () { Link Here
585
                </div>\
591
                </div>\
586
\
592
\
587
                <div class='modal-body'>\
593
                <div class='modal-body'>\
588
                    <input type='hidden' id='suspend-modal-reserve_id' name='reserve_id' />\
589
\
594
\
590
                    <label for='suspend-modal-until'>" +
595
                    <label for='suspend-modal-until'>" +
591
            __("Suspend until:") +
596
            __("Suspend until:") +
Lines 606-611 $(document).ready(function () { Link Here
606
            __("Cancel") +
611
            __("Cancel") +
607
            "</button>\
612
            "</button>\
608
                </div>\
613
                </div>\
614
                <div id='suspend-selected-container'></div>\
609
            </form>\
615
            </form>\
610
            </div>\
616
            </div>\
611
            </div>\
617
            </div>\
Lines 619-649 $(document).ready(function () { Link Here
619
625
620
    $("#suspend-modal-submit").on("click", function (e) {
626
    $("#suspend-modal-submit").on("click", function (e) {
621
        e.preventDefault();
627
        e.preventDefault();
628
        let selected_holds;
629
        if (!$(this).data("hold-id")) {
630
            selected_holds =
631
                "[" +
632
                $(".holds_table .select_hold:checked")
633
                    .toArray()
634
                    .map(el =>
635
                        JSON.stringify({
636
                            hold: $(el).data("id"),
637
                            borrowernumber: $(el).data("borrowernumber"),
638
                            biblionumber: $(el).data("biblionumber"),
639
                        })
640
                    )
641
                    .join(",") +
642
                "]";
643
        } else {
644
            selected_holds =
645
                "[" + JSON.stringify({ hold: $(this).data("hold-id") }) + "]";
646
            $(this).removeData("hold-id");
647
        }
648
622
        var suspend_until_date = $("#suspend-modal-until").val();
649
        var suspend_until_date = $("#suspend-modal-until").val();
623
        if (suspend_until_date !== null)
650
        if (suspend_until_date !== null)
624
            suspend_until_date = $date(suspend_until_date, {
651
            suspend_until_date = $date(suspend_until_date, {
625
                dateformat: "rfc3339",
652
                dateformat: "rfc3339",
626
            });
653
            });
627
        suspend_hold($(this).data("hold-id"), suspend_until_date)
654
628
            .success(function () {
655
        const hold_ids = JSON.parse(selected_holds).map(hold => hold.hold);
629
                holdsTable.api().ajax.reload();
656
        try {
630
            })
657
            suspend_hold(hold_ids, suspend_until_date)
631
            .error(function (jqXHR, textStatus, errorThrown) {
658
                .success(function () {
632
                if (jqXHR.status === 404) {
659
                    holdsTable.api().ajax.reload();
633
                    alert(__("Unable to suspend, hold not found."));
660
                })
634
                } else {
661
                .done(function () {
635
                    alert(
662
                    if ($("#suspend-modal-until").length) {
636
                        __(
663
                        $("#suspend-modal-until").flatpickr().clear(); // clean the input
637
                            "Your request could not be processed. Check the logs for details."
664
                    }
638
                        )
665
                    $("#suspend-modal").modal("hide");
639
                    );
666
                    $(".select_hold_all").click();
640
                }
667
                });
641
                holdsTable.api().ajax.reload();
668
        } catch (error) {
642
            })
669
            if (error.status === 404) {
643
            .done(function () {
670
                alert(__("Unable to suspend, hold not found."));
644
                $("#suspend-modal-until").flatpickr().clear(); // clean the input
671
            } else {
645
                $("#suspend-modal").modal("hide");
672
                alert(
646
            });
673
                    __(
674
                        "Your request could not be processed. Check the logs for details."
675
                    )
676
                );
677
            }
678
        }
647
    });
679
    });
648
680
649
    function toggle_suspend(node, inputs) {
681
    function toggle_suspend(node, inputs) {
Lines 688-694 $(document).ready(function () { Link Here
688
    });
720
    });
689
721
690
    var MSG_SUSPEND_SELECTED = _("Suspend selected (%s)");
722
    var MSG_SUSPEND_SELECTED = _("Suspend selected (%s)");
691
    var MSG_SUSPEND_SELECTED_HOLDS = _("Suspend selected holds");
723
    var MSG_SUSPEND_SELECTED_HOLDS = _("selected holds");
692
    $(".suspend_selected_holds").html(
724
    $(".suspend_selected_holds").html(
693
        MSG_SUSPEND_SELECTED.format(
725
        MSG_SUSPEND_SELECTED.format(
694
            $(".holds_table .select_hold:checked").length
726
            $(".holds_table .select_hold:checked").length
Lines 700-706 $(document).ready(function () { Link Here
700
        if (!$(".holds_table .select_hold:checked").length) {
732
        if (!$(".holds_table .select_hold:checked").length) {
701
            return false;
733
            return false;
702
        }
734
        }
703
        $(".modal-title").html(MSG_SUSPEND_SELECTED_HOLDS);
735
        $("#suspend-modal-title").html(MSG_SUSPEND_SELECTED_HOLDS);
704
        $("#suspend-modal").modal("show");
736
        $("#suspend-modal").modal("show");
705
        return false;
737
        return false;
706
    });
738
    });
707
- 

Return to bug 40395