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

(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/circulation.tt (-100 / +3 lines)
Lines 1034-1139 Link Here
1034
        table_settings_relatives_issues_table = [% TablesSettings.GetTableSettings( 'circ', 'circulation', 'relatives-issues-table', 'json' ) | $raw %]
1034
        table_settings_relatives_issues_table = [% TablesSettings.GetTableSettings( 'circ', 'circulation', 'relatives-issues-table', 'json' ) | $raw %]
1035
        table_settings_holds_table = [% TablesSettings.GetTableSettings( 'circ', 'circulation', 'holds-table', 'json' ) | $raw %]
1035
        table_settings_holds_table = [% TablesSettings.GetTableSettings( 'circ', 'circulation', 'holds-table', 'json' ) | $raw %]
1036
        table_settings_bookings_table = [% TablesSettings.GetTableSettings( 'members', 'moremember', 'bookings-table', 'json' ) | $raw %]
1036
        table_settings_bookings_table = [% TablesSettings.GetTableSettings( 'members', 'moremember', 'bookings-table', 'json' ) | $raw %]
1037
1037
        CAN_user_circulate_manage_bookings = [% CAN_user_circulate_manage_bookings | $raw %]
1038
        var bookings_table;
1038
        patron_borrowernumber = [% patron.borrowernumber | $raw %]
1039
        $(document).ready(function() {
1040
            $("#info_digests").tooltip();
1041
1042
            $("#finesholdsissues a[data-toggle='tab']").on("shown.bs.tab", function(e){
1043
                var oTable = $('div.dataTables_wrapper > table', $(e.target.hash) ).dataTable();
1044
                if ( oTable.length > 0 ) {
1045
                    oTable.fnAdjustColumnSizing();
1046
                }
1047
            });
1048
1049
            $("#view_restrictions").on("click",function(){
1050
                $('#reldebarments-tab').click();
1051
            });
1052
1053
            $("#view_guarantees_finesandcharges").on("click",function(){
1054
                $('#guarantees_finesandcharges-tab').click();
1055
            });
1056
1057
            // Bookings
1058
            // Load bookings table on tab selection
1059
            $("#bookings-tab").on( "click", function(){
1060
                if ( !bookings_table ) {
1061
                    var today = new Date();
1062
                    var bookings_table_url = "/api/v1/bookings";
1063
                    bookings_table = $('#bookings_table').kohaTable({
1064
                        "ajax": {
1065
                            "url": bookings_table_url
1066
                        },
1067
                        "embed": [
1068
                            "biblio",
1069
                            "item",
1070
                            "patron"
1071
                        ],
1072
                        "columns": [{
1073
                            "data": "booking_id",
1074
                            "title": _("Booking ID"),
1075
                        },
1076
                        {
1077
                            "data": "biblio.title",
1078
                            "title": _("Title"),
1079
                            "searchable": true,
1080
                            "orderable": true,
1081
                            "render": function(data,type,row,meta) {
1082
                                return $biblio_to_html(row.biblio, {
1083
                                    link: 'bookings'
1084
                                });
1085
                            }
1086
                        },
1087
                        {
1088
                            "data": "item.external_id",
1089
                            "title": _("Item"),
1090
                            "searchable": true,
1091
                            "orderable": true,
1092
                            "defaultContent": _("Any item"),
1093
                            "render": function(data,type,row,meta) {
1094
                                if ( row.item ) {
1095
                                    return row.item.external_id + " (" + row.booking_id + ")";
1096
                                } else {
1097
                                    return null;
1098
                                }
1099
                            }
1100
                        },
1101
                        {
1102
                            "data": "start_date",
1103
                            "title": _("Start date"),
1104
                            "searchable": true,
1105
                            "orderable": true,
1106
                            "render": function(data, type, row, meta) {
1107
                                return $date(row.start_date);
1108
                            }
1109
                        },
1110
                        {
1111
                            "data": "end_date",
1112
                            "title": _("End date"),
1113
                            "searchable": true,
1114
                            "orderable": true,
1115
                            "render": function(data, type, row, meta) {
1116
                                return $date(row.end_date);
1117
                            }
1118
                        },
1119
                        {
1120
                            "data": "",
1121
                            "title": _("Actions"),
1122
                            "class": "actions",
1123
                            "searchable": false,
1124
                            "orderable": false,
1125
                            "render": function(data, type, row, meta) {
1126
                                let result = "";
1127
                                [% IF CAN_user_circulate_manage_bookings %]
1128
                                result += '<button type="button" class="btn btn-default btn-xs cancel-action" data-toggle="modal" data-target="#cancelBookingModal" data-booking="'+row.booking_id+'"><i class="fa fa-trash" aria-hidden="true"></i> '+_("Cancel")+'</button>';
1129
                                [% END %]
1130
                                return result;
1131
                            }
1132
                        }]
1133
                    }, table_settings_bookings_table, 0, { patron_id: "[% patron.borrowernumber | html %]", end_date: { ">=": today.toISOString() } });
1134
                };
1135
            });
1136
         });
1137
1039
1138
        [% IF borrowernumber and patron %]
1040
        [% IF borrowernumber and patron %]
1139
            if( Cookies.get("holdfor") != [% patron.borrowernumber | html %]){
1041
            if( Cookies.get("holdfor") != [% patron.borrowernumber | html %]){
Lines 1235-1240 Link Here
1235
    </script>
1137
    </script>
1236
    [% INCLUDE 'str/members-menu.inc' %]
1138
    [% INCLUDE 'str/members-menu.inc' %]
1237
    [% Asset.js("js/members-menu.js") | $raw %]
1139
    [% Asset.js("js/members-menu.js") | $raw %]
1140
    [% Asset.js("js/bookings-table.js") | $raw %]
1238
    [% Asset.js("js/recalls.js") | $raw %]
1141
    [% Asset.js("js/recalls.js") | $raw %]
1239
[% END %]
1142
[% END %]
1240
1143
(-)a/koha-tmpl/intranet-tmpl/prog/js/bookings-table.js (-1 / +123 lines)
Line 0 Link Here
0
- 
1
$(document).ready(function () {
2
    var bookings_table;
3
    $(document).ready(function () {
4
        $("#info_digests").tooltip();
5
6
        $("#finesholdsissues a[data-toggle='tab']").on(
7
            "shown.bs.tab",
8
            function (e) {
9
                var oTable = $(
10
                    "div.dataTables_wrapper > table",
11
                    $(e.target.hash)
12
                ).dataTable();
13
                if (oTable.length > 0) {
14
                    oTable.fnAdjustColumnSizing();
15
                }
16
            }
17
        );
18
19
        $("#view_restrictions").on("click", function () {
20
            $("#reldebarments-tab").click();
21
        });
22
23
        $("#view_guarantees_finesandcharges").on("click", function () {
24
            $("#guarantees_finesandcharges-tab").click();
25
        });
26
27
        // Bookings
28
        // Load bookings table on tab selection
29
        $("#bookings-tab").on("click", function () {
30
            if (!bookings_table) {
31
                var today = new Date();
32
                var bookings_table_url = "/api/v1/bookings";
33
                bookings_table = $("#bookings_table").kohaTable(
34
                    {
35
                        ajax: {
36
                            url: bookings_table_url,
37
                        },
38
                        embed: ["biblio", "item", "patron"],
39
                        columns: [
40
                            {
41
                                data: "booking_id",
42
                                title: _("Booking ID"),
43
                            },
44
                            {
45
                                data: "biblio.title",
46
                                title: _("Title"),
47
                                searchable: true,
48
                                orderable: true,
49
                                render: function (data, type, row, meta) {
50
                                    return $biblio_to_html(row.biblio, {
51
                                        link: "bookings",
52
                                    });
53
                                },
54
                            },
55
                            {
56
                                data: "item.external_id",
57
                                title: _("Item"),
58
                                searchable: true,
59
                                orderable: true,
60
                                defaultContent: _("Any item"),
61
                                render: function (data, type, row, meta) {
62
                                    if (row.item) {
63
                                        return (
64
                                            row.item.external_id +
65
                                            " (" +
66
                                            row.booking_id +
67
                                            ")"
68
                                        );
69
                                    } else {
70
                                        return null;
71
                                    }
72
                                },
73
                            },
74
                            {
75
                                data: "start_date",
76
                                title: _("Start date"),
77
                                searchable: true,
78
                                orderable: true,
79
                                render: function (data, type, row, meta) {
80
                                    return $date(row.start_date);
81
                                },
82
                            },
83
                            {
84
                                data: "end_date",
85
                                title: _("End date"),
86
                                searchable: true,
87
                                orderable: true,
88
                                render: function (data, type, row, meta) {
89
                                    return $date(row.end_date);
90
                                },
91
                            },
92
                            {
93
                                data: "",
94
                                title: _("Actions"),
95
                                class: "actions",
96
                                searchable: false,
97
                                orderable: false,
98
                                render: function (data, type, row, meta) {
99
                                    let result = "";
100
                                    if (CAN_user_circulate_manage_bookings) {
101
                                        result +=
102
                                            '<button type="button" class="btn btn-default btn-xs cancel-action" data-toggle="modal" data-target="#cancelBookingModal" data-booking="' +
103
                                            row.booking_id +
104
                                            '"><i class="fa fa-trash" aria-hidden="true"></i> ' +
105
                                            _("Cancel") +
106
                                            "</button>";
107
                                    }
108
                                    return result;
109
                                },
110
                            },
111
                        ],
112
                    },
113
                    table_settings_bookings_table,
114
                    0,
115
                    {
116
                        patron_id: patron_borrowernumber,
117
                        end_date: { ">=": today.toISOString() },
118
                    }
119
                );
120
            }
121
        });
122
    });
123
});

Return to bug 37047