|
Lines 9-19
Link Here
|
| 9 |
[% PROCESS 'i18n.inc' %] |
9 |
[% PROCESS 'i18n.inc' %] |
| 10 |
[% SET footerjs = 1 %] |
10 |
[% SET footerjs = 1 %] |
| 11 |
[% INCLUDE 'doc-head-open.inc' %] |
11 |
[% INCLUDE 'doc-head-open.inc' %] |
| 12 |
<title>[% FILTER collapse %] |
12 |
<title |
| 13 |
[% t("Items available for booking") | html %] › |
13 |
>[% FILTER collapse %] |
| 14 |
[% t("Circulation") | html %] › |
14 |
[% t("Items available for booking") | html %] |
| 15 |
[% t("Koha") | html %] |
15 |
› [% t("Circulation") | html %] › [% t("Koha") | html %] |
| 16 |
[% END %]</title> |
16 |
[% END %]</title |
|
|
17 |
> |
| 17 |
[% INCLUDE 'doc-head-close.inc' %] |
18 |
[% INCLUDE 'doc-head-close.inc' %] |
| 18 |
</head> |
19 |
</head> |
| 19 |
|
20 |
|
|
Lines 35-41
Link Here
|
| 35 |
|
36 |
|
| 36 |
<div class="main container-fluid"> |
37 |
<div class="main container-fluid"> |
| 37 |
<div class="row"> |
38 |
<div class="row"> |
| 38 |
|
|
|
| 39 |
<!-- Results --> |
39 |
<!-- Results --> |
| 40 |
<div class="col-md-10 order-md-2 order-sm1"> |
40 |
<div class="col-md-10 order-md-2 order-sm1"> |
| 41 |
<main> |
41 |
<main> |
|
Lines 57-67
Link Here
|
| 57 |
<ol> |
57 |
<ol> |
| 58 |
<li> |
58 |
<li> |
| 59 |
<label for="start_date">Start date: </label> |
59 |
<label for="start_date">Start date: </label> |
| 60 |
<input type="text" size="10" id="start_date" name="start_date" value="[% start_date_default | html %]" class="flatpickr" data-date_to="end_date" required/> |
60 |
<input type="text" size="10" id="start_date" name="start_date" value="[% start_date_default | html %]" class="flatpickr" data-date_to="end_date" required /> |
| 61 |
</li> |
61 |
</li> |
| 62 |
<li> |
62 |
<li> |
| 63 |
<label for="end_date">End date: </label> |
63 |
<label for="end_date">End date: </label> |
| 64 |
<input type="text" size="10" id="end_date" name="end_date" value="[% end_date_default | html %]" class="flatpickr" required/> |
64 |
<input type="text" size="10" id="end_date" name="end_date" value="[% end_date_default | html %]" class="flatpickr" required /> |
| 65 |
</li> |
65 |
</li> |
| 66 |
<li> |
66 |
<li> |
| 67 |
<label for="pickup_libraries">Pickup libraries:</label> |
67 |
<label for="pickup_libraries">Pickup libraries:</label> |
|
Lines 98-276
Link Here
|
| 98 |
</div> |
98 |
</div> |
| 99 |
|
99 |
|
| 100 |
[% MACRO jsinclude BLOCK %] |
100 |
[% MACRO jsinclude BLOCK %] |
| 101 |
[% INCLUDE 'calendar.inc' %] |
101 |
[% INCLUDE 'calendar.inc' %] |
| 102 |
[% INCLUDE 'datatables.inc' %] |
102 |
[% INCLUDE 'datatables.inc' %] |
| 103 |
[% INCLUDE 'js-biblio-format.inc' %] |
103 |
[% INCLUDE 'js-biblio-format.inc' %] |
| 104 |
[% INCLUDE 'js-date-format.inc' %] |
104 |
[% INCLUDE 'js-date-format.inc' %] |
| 105 |
|
105 |
<script> |
| 106 |
<script> |
106 |
let table_settings = [% TablesSettings.GetTableSettings( 'circ', 'available-bookings', 'available-items', 'json' ) | $raw %]; |
| 107 |
let table_settings = [% TablesSettings.GetTableSettings( 'circ', 'available-bookings', 'available-items', 'json' ) | $raw %]; |
|
|
| 108 |
|
107 |
|
| 109 |
$(document).ready(function() { |
108 |
$(document).ready(function() { |
| 110 |
|
109 |
|
| 111 |
let additional_filters = { |
110 |
let additional_filters = { |
| 112 |
'me.holding_library_id': function() { |
111 |
'me.holding_library_id': function() { |
| 113 |
let selectedLibraries = $("#pickup_libraries").val(); |
112 |
let selectedLibraries = $("#pickup_libraries").val(); |
| 114 |
if (selectedLibraries && selectedLibraries.length > 0) { |
113 |
if (selectedLibraries && selectedLibraries.length > 0) { |
| 115 |
selectedLibraries = selectedLibraries.filter(lib => lib !== ''); |
114 |
selectedLibraries = selectedLibraries.filter(lib => lib !== ''); |
| 116 |
if (selectedLibraries.length > 0) { |
115 |
if (selectedLibraries.length > 0) { |
| 117 |
return selectedLibraries; |
116 |
return selectedLibraries; |
|
|
117 |
} |
| 118 |
} |
| 119 |
return; |
| 120 |
}, |
| 121 |
'me.item_type_id': function() { |
| 122 |
let itemType = $("#item_type").val(); |
| 123 |
if (itemType && itemType !== '') { |
| 124 |
return itemType; |
| 125 |
} |
| 126 |
return; |
| 118 |
} |
127 |
} |
| 119 |
} |
128 |
}; |
| 120 |
return; |
|
|
| 121 |
}, |
| 122 |
'me.item_type_id': function() { |
| 123 |
let itemType = $("#item_type").val(); |
| 124 |
if (itemType && itemType !== '') { |
| 125 |
return itemType; |
| 126 |
} |
| 127 |
return; |
| 128 |
} |
| 129 |
}; |
| 130 |
|
129 |
|
| 131 |
[% SET libraries = Branches.all %] |
130 |
[% SET libraries = Branches.all %] |
| 132 |
let all_libraries = [% To.json(libraries) | $raw %].map(e => { |
131 |
let all_libraries = [% To.json(libraries) | $raw %].map(e => { |
| 133 |
e['_id'] = e.branchcode; |
132 |
e['_id'] = e.branchcode; |
| 134 |
e['_str'] = e.branchname; |
133 |
e['_str'] = e.branchname; |
| 135 |
return e; |
134 |
return e; |
| 136 |
}); |
135 |
}); |
| 137 |
let filters_options = {}; |
136 |
let filters_options = {}; |
| 138 |
|
137 |
|
| 139 |
var available_items_table_url = '/api/v1/items/available_for_booking'; |
138 |
var available_items_table_url = '/api/v1/items/available_for_booking'; |
| 140 |
|
139 |
|
| 141 |
var available_items_table = $("#available_items_table").kohaTable({ |
140 |
var available_items_table = $("#available_items_table").kohaTable({ |
| 142 |
"ajax": { |
141 |
"ajax": { |
| 143 |
"url": available_items_table_url |
142 |
"url": available_items_table_url |
| 144 |
}, |
143 |
}, |
| 145 |
"embed": [ |
144 |
"embed": [ |
| 146 |
"biblio", |
145 |
"biblio", |
| 147 |
"+strings", |
146 |
"+strings", |
| 148 |
"home_library", |
147 |
"home_library", |
| 149 |
"holding_library", |
148 |
"holding_library", |
| 150 |
"item_type" |
149 |
"item_type" |
| 151 |
], |
150 |
], |
| 152 |
"order": [[ 2, "asc" ]], |
151 |
"order": [[ 2, "asc" ]], |
| 153 |
"columns": [{ |
152 |
"columns": [{ |
| 154 |
"data": "home_library.name", |
153 |
"data": "home_library.name", |
| 155 |
"title": _("Homebranch"), |
154 |
"title": _("Homebranch"), |
| 156 |
"searchable": true, |
155 |
"searchable": true, |
| 157 |
"orderable": true, |
156 |
"orderable": true, |
| 158 |
"render": function( data, type, row, meta ) { |
157 |
"render": function( data, type, row, meta ) { |
| 159 |
return escape_str(row.home_library_id ? row.home_library.name : row.home_library_id); |
158 |
return escape_str(row.home_library_id ? row.home_library.name : row.home_library_id); |
| 160 |
} |
159 |
} |
| 161 |
}, |
160 |
}, |
| 162 |
{ |
161 |
{ |
| 163 |
"data": "holding_library.name", |
162 |
"data": "holding_library.name", |
| 164 |
"title": _("Pickup library"), |
163 |
"title": _("Pickup library"), |
| 165 |
"searchable": true, |
164 |
"searchable": true, |
| 166 |
"orderable": true, |
165 |
"orderable": true, |
| 167 |
"render": function( data, type, row, meta ) { |
166 |
"render": function( data, type, row, meta ) { |
| 168 |
return escape_str(row.holding_library_id ? row.holding_library.name : row.holding_library_id); |
167 |
return escape_str(row.holding_library_id ? row.holding_library.name : row.holding_library_id); |
| 169 |
} |
168 |
} |
| 170 |
}, |
169 |
}, |
| 171 |
{ |
170 |
{ |
| 172 |
"data": "biblio.title", |
171 |
"data": "biblio.title", |
| 173 |
"title": _("Title"), |
172 |
"title": _("Title"), |
| 174 |
"searchable": true, |
173 |
"searchable": true, |
| 175 |
"orderable": true, |
174 |
"orderable": true, |
| 176 |
"render": function(data,type,row,meta) { |
175 |
"render": function(data,type,row,meta) { |
| 177 |
if ( row.biblio ) { |
176 |
if ( row.biblio ) { |
| 178 |
return $biblio_to_html(row.biblio, { |
177 |
return $biblio_to_html(row.biblio, { |
| 179 |
link: 'detail' |
178 |
link: 'detail' |
| 180 |
}); |
179 |
}); |
| 181 |
} else { |
180 |
} else { |
| 182 |
return 'No title'; |
181 |
return 'No title'; |
| 183 |
} |
182 |
} |
| 184 |
} |
183 |
} |
| 185 |
}, |
184 |
}, |
| 186 |
{ |
185 |
{ |
| 187 |
"data": "item_type_id", |
186 |
"data": "item_type_id", |
| 188 |
"title": _("Item type"), |
187 |
"title": _("Item type"), |
| 189 |
"searchable": true, |
188 |
"searchable": true, |
| 190 |
"orderable": true, |
189 |
"orderable": true, |
| 191 |
"render": function(data,type,row,meta) { |
190 |
"render": function(data,type,row,meta) { |
| 192 |
if ( row.item_type && row.item_type.description ) { |
191 |
if ( row.item_type && row.item_type.description ) { |
| 193 |
return escape_str(row.item_type.description); |
192 |
return escape_str(row.item_type.description); |
| 194 |
} else if ( row._strings && row._strings.item_type_id ) { |
193 |
} else if ( row._strings && row._strings.item_type_id ) { |
| 195 |
return escape_str(row._strings.item_type_id.str); |
194 |
return escape_str(row._strings.item_type_id.str); |
| 196 |
} else { |
195 |
} else { |
| 197 |
return escape_str(row.item_type_id || ''); |
196 |
return escape_str(row.item_type_id || ''); |
| 198 |
} |
197 |
} |
| 199 |
} |
198 |
} |
| 200 |
}, |
199 |
}, |
| 201 |
{ |
200 |
{ |
| 202 |
"data": "external_id", |
201 |
"data": "external_id", |
| 203 |
"title": _("Barcode"), |
202 |
"title": _("Barcode"), |
| 204 |
"searchable": true, |
203 |
"searchable": true, |
| 205 |
"orderable": true |
204 |
"orderable": true |
| 206 |
}, |
205 |
}, |
| 207 |
{ |
206 |
{ |
| 208 |
"data": "callnumber", |
207 |
"data": "callnumber", |
| 209 |
"title": _("Callnumber"), |
208 |
"title": _("Callnumber"), |
| 210 |
"searchable": true, |
209 |
"searchable": true, |
| 211 |
"orderable": true |
210 |
"orderable": true |
| 212 |
}, |
211 |
}, |
| 213 |
{ |
212 |
{ |
| 214 |
"data": "location", |
213 |
"data": "location", |
| 215 |
"title": _("Location"), |
214 |
"title": _("Location"), |
| 216 |
"searchable": true, |
215 |
"searchable": true, |
| 217 |
"orderable": true, |
216 |
"orderable": true, |
| 218 |
"render": function(data,type,row,meta) { |
217 |
"render": function(data,type,row,meta) { |
| 219 |
if ( row._strings && row._strings.location ) { |
218 |
if ( row._strings && row._strings.location ) { |
| 220 |
return row._strings.location.str; |
219 |
return row._strings.location.str; |
| 221 |
} else { |
220 |
} else { |
| 222 |
return row.location || ''; |
221 |
return row.location || ''; |
| 223 |
} |
222 |
} |
| 224 |
} |
223 |
} |
| 225 |
}, |
224 |
}, |
| 226 |
{ |
225 |
{ |
| 227 |
"data": "localuse", |
226 |
"data": "localuse", |
| 228 |
"title": _("Local use"), |
227 |
"title": _("Local use"), |
| 229 |
"searchable": true, |
228 |
"searchable": true, |
| 230 |
"orderable": true |
229 |
"orderable": true |
| 231 |
}] |
230 |
}] |
| 232 |
}, table_settings, 1, additional_filters, filters_options); |
231 |
}, table_settings, 1, additional_filters, filters_options); |
| 233 |
|
232 |
|
| 234 |
$("#available_items_filter").on("submit", function(e){ |
233 |
$("#available_items_filter").on("submit", function(e){ |
| 235 |
e.preventDefault(); |
234 |
e.preventDefault(); |
| 236 |
|
235 |
|
| 237 |
if (!$("#start_date").val() || !$("#end_date").val()) { |
236 |
if (!$("#start_date").val() || !$("#end_date").val()) { |
| 238 |
alert("Please select both start and end dates"); |
237 |
alert("Please select both start and end dates"); |
| 239 |
return false; |
238 |
return false; |
| 240 |
} |
239 |
} |
| 241 |
let newUrl = '/api/v1/items/available_for_booking'; |
240 |
let newUrl = '/api/v1/items/available_for_booking'; |
| 242 |
let params = []; |
241 |
let params = []; |
| 243 |
|
242 |
|
| 244 |
let fromdate = $("#start_date"); |
243 |
let fromdate = $("#start_date"); |
| 245 |
let todate = $("#end_date"); |
244 |
let todate = $("#end_date"); |
| 246 |
if ( fromdate.val() !== '' && todate.val() !== '' ) { |
245 |
if ( fromdate.val() !== '' && todate.val() !== '' ) { |
| 247 |
let fromDateStr = fromdate.val(); |
246 |
let fromDateStr = fromdate.val(); |
| 248 |
let toDateStr = todate.val(); |
247 |
let toDateStr = todate.val(); |
| 249 |
params.push('start_date=' + encodeURIComponent(fromDateStr)); |
248 |
params.push('start_date=' + encodeURIComponent(fromDateStr)); |
| 250 |
params.push('end_date=' + encodeURIComponent(toDateStr)); |
249 |
params.push('end_date=' + encodeURIComponent(toDateStr)); |
| 251 |
|
250 |
|
| 252 |
} |
251 |
} |
| 253 |
if (params.length > 0) { |
252 |
if (params.length > 0) { |
| 254 |
newUrl += '?' + params.join('&'); |
253 |
newUrl += '?' + params.join('&'); |
| 255 |
} |
254 |
} |
| 256 |
available_items_table.DataTable().ajax.url(newUrl).load(); |
255 |
available_items_table.DataTable().ajax.url(newUrl).load(); |
| 257 |
}); |
256 |
}); |
| 258 |
|
257 |
|
| 259 |
$("#available_items_filter input[type=reset]").on("click", function(e){ |
258 |
$("#available_items_filter input[type=reset]").on("click", function(e){ |
| 260 |
$("#pickup_libraries").val([]); |
259 |
$("#pickup_libraries").val([]); |
| 261 |
$("#item_type").val(''); |
260 |
$("#item_type").val(''); |
| 262 |
$("#start_date").val('[% start_date_default | html %]'); |
261 |
$("#start_date").val('[% start_date_default | html %]'); |
| 263 |
$("#end_date").val('[% end_date_default | html %]'); |
262 |
$("#end_date").val('[% end_date_default | html %]'); |
| 264 |
|
263 |
|
| 265 |
let resetUrl = '/api/v1/items/available_for_booking'; |
264 |
let resetUrl = '/api/v1/items/available_for_booking'; |
| 266 |
if ('[% start_date_default %]' && '[% end_date_default %]') { |
265 |
if ('[% start_date_default | html %]' && '[% end_date_default | html %]') { |
| 267 |
resetUrl += '?start_date=[% start_date_default | uri %]&end_date=[% end_date_default | uri %]'; |
266 |
resetUrl += '?start_date=[% start_date_default | uri %]&end_date=[% end_date_default | uri %]'; |
| 268 |
} |
267 |
} |
| 269 |
available_items_table.DataTable().ajax.url(resetUrl).load(); |
268 |
available_items_table.DataTable().ajax.url(resetUrl).load(); |
| 270 |
}); |
269 |
}); |
| 271 |
|
270 |
|
| 272 |
}); |
271 |
}); |
| 273 |
</script> |
272 |
</script> |
| 274 |
[% END %] |
273 |
[% END %] |
| 275 |
|
274 |
|
| 276 |
[% INCLUDE 'intranet-bottom.inc' %] |
275 |
[% INCLUDE 'intranet-bottom.inc' %] |
| 277 |
- |
|
|