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