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

(-)a/koha-tmpl/intranet-tmpl/prog/js/tables/bookings.js (-91 / +88 lines)
Lines 1-102 Link Here
1
/* keep tidy */
1
/* keep tidy */
2
// Bookings
2
// Bookings
3
var bookings_table;
3
$(document).ready(function () {
4
$(document).ready(function () {
4
    var bookings_table;
5
    $(document).ready(function () {
6
5
7
        // Load bookings table on tab selection
6
    // Load bookings table on tab selection
8
        $("#bookings-tab").on("click", function () {
7
    $("#bookings-tab").on("click", function () {
9
            if (!bookings_table) {
8
        if (!bookings_table) {
10
                var today = new Date();
9
            var today = new Date();
11
                var bookings_table_url = "/api/v1/bookings";
10
            var bookings_table_url = "/api/v1/bookings";
12
                bookings_table = $("#bookings_table").kohaTable(
11
            bookings_table = $("#bookings_table").kohaTable(
13
                    {
12
                {
14
                        ajax: {
13
                    ajax: {
15
                            url: bookings_table_url,
14
                        url: bookings_table_url,
15
                    },
16
                    embed: ["biblio", "item", "patron"],
17
                    columns: [
18
                        {
19
                            data: "booking_id",
20
                            title: _("Booking ID"),
16
                        },
21
                        },
17
                        embed: ["biblio", "item", "patron"],
22
                        {
18
                        columns: [
23
                            data: "biblio.title",
19
                            {
24
                            title: _("Title"),
20
                                data: "booking_id",
25
                            searchable: true,
21
                                title: _("Booking ID"),
26
                            orderable: true,
22
                            },
27
                            render: function (data, type, row, meta) {
23
                            {
28
                                return $biblio_to_html(row.biblio, {
24
                                data: "biblio.title",
29
                                    link: "bookings",
25
                                title: _("Title"),
30
                                });
26
                                searchable: true,
27
                                orderable: true,
28
                                render: function (data, type, row, meta) {
29
                                    return $biblio_to_html(row.biblio, {
30
                                        link: "bookings",
31
                                    });
32
                                },
33
                            },
31
                            },
34
                            {
32
                        },
35
                                data: "item.external_id",
33
                        {
36
                                title: _("Item"),
34
                            data: "item.external_id",
37
                                searchable: true,
35
                            title: _("Item"),
38
                                orderable: true,
36
                            searchable: true,
39
                                defaultContent: _("Any item"),
37
                            orderable: true,
40
                                render: function (data, type, row, meta) {
38
                            defaultContent: _("Any item"),
41
                                    if (row.item) {
39
                            render: function (data, type, row, meta) {
42
                                        return (
40
                                if (row.item) {
43
                                            row.item.external_id +
41
                                    return (
44
                                            " (" +
42
                                        row.item.external_id +
45
                                            row.booking_id +
43
                                        " (" +
46
                                            ")"
44
                                        row.booking_id +
47
                                        );
45
                                        ")"
48
                                    } else {
46
                                    );
49
                                        return null;
47
                                } else {
50
                                    }
48
                                    return null;
51
                                },
49
                                }
52
                            },
50
                            },
53
                            {
51
                        },
54
                                data: "start_date",
52
                        {
55
                                title: _("Start date"),
53
                            data: "start_date",
56
                                searchable: true,
54
                            title: _("Start date"),
57
                                orderable: true,
55
                            searchable: true,
58
                                render: function (data, type, row, meta) {
56
                            orderable: true,
59
                                    return $date(row.start_date);
57
                            render: function (data, type, row, meta) {
60
                                },
58
                                return $date(row.start_date);
61
                            },
59
                            },
62
                            {
60
                        },
63
                                data: "end_date",
61
                        {
64
                                title: _("End date"),
62
                            data: "end_date",
65
                                searchable: true,
63
                            title: _("End date"),
66
                                orderable: true,
64
                            searchable: true,
67
                                render: function (data, type, row, meta) {
65
                            orderable: true,
68
                                    return $date(row.end_date);
66
                            render: function (data, type, row, meta) {
69
                                },
67
                                return $date(row.end_date);
70
                            },
68
                            },
71
                            {
69
                        },
72
                                data: "",
70
                        {
73
                                title: _("Actions"),
71
                            data: "",
74
                                class: "actions",
72
                            title: _("Actions"),
75
                                searchable: false,
73
                            class: "actions",
76
                                orderable: false,
74
                            searchable: false,
77
                                render: function (data, type, row, meta) {
75
                            orderable: false,
78
                                    let result = "";
76
                            render: function (data, type, row, meta) {
79
                                    if (CAN_user_circulate_manage_bookings) {
77
                                let result = "";
80
                                        result +=
78
                                if (CAN_user_circulate_manage_bookings) {
81
                                            '<button type="button" class="btn btn-default btn-xs cancel-action" data-toggle="modal" data-target="#cancelBookingModal" data-booking="' +
79
                                    result +=
82
                                            row.booking_id +
80
                                        '<button type="button" class="btn btn-default btn-xs cancel-action" data-toggle="modal" data-target="#cancelBookingModal" data-booking="' +
83
                                            '"><i class="fa fa-trash" aria-hidden="true"></i> ' +
81
                                        row.booking_id +
84
                                            _("Cancel") +
82
                                        '"><i class="fa fa-trash" aria-hidden="true"></i> ' +
85
                                            "</button>";
83
                                        _("Cancel") +
86
                                    }
84
                                        "</button>";
87
                                    return result;
85
                                }
88
                                },
86
                                return result;
89
                            },
87
                            },
90
                        ],
88
                        },
91
                    },
89
                    ],
92
                    table_settings_bookings_table,
90
                },
93
                    0,
91
                table_settings_bookings_table,
94
                    {
92
                0,
95
                        patron_id: patron_borrowernumber,
93
                {
96
                        end_date: { ">=": today.toISOString() },
94
                    patron_id: patron_borrowernumber,
97
                    }
95
                    end_date: { ">=": today.toISOString() },
98
                );
96
                }
99
            }
97
            );
100
        });
98
        }
101
    });
99
    });
102
});
100
});
103
- 

Return to bug 37047