Lines 1-123
Link Here
|
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 |
}); |
124 |
- |