|
Lines 152-180
Link Here
|
| 152 |
</tr> |
152 |
</tr> |
| 153 |
</thead> |
153 |
</thead> |
| 154 |
<tbody> |
154 |
<tbody> |
| 155 |
[% FOREACH request IN requests %] |
|
|
| 156 |
[% status = request.status | html %] |
| 157 |
[% type = request.get_type %] |
| 158 |
<tr> |
| 159 |
<td>[% request.id | html %]</td> |
| 160 |
<td> |
| 161 |
[% IF request.metadata.Author %][% request.metadata.Author | html %][% ELSE %]<span>N/A</span>[% END %] |
| 162 |
</td> |
| 163 |
<td> |
| 164 |
[% IF request.metadata.Title %][% request.metadata.Title | html %][% ELSE %]<span>N/A</span>[% END %] |
| 165 |
</td> |
| 166 |
<td>[% request.backend | html %]</td> |
| 167 |
<td> |
| 168 |
[% IF type %][% type | html %][% ELSE %]<span>N/A</span>[% END %] |
| 169 |
</td> |
| 170 |
<td>[% request.status_alias ? request.statusalias.lib_opac : request.capabilities.$status.name | html %]</td> |
| 171 |
<td data-order="[% request.placed | html %]">[% request.placed | $KohaDates %]</td> |
| 172 |
<td data-order="[% request.updated | html %]">[% request.updated | $KohaDates %]</td> |
| 173 |
<td> |
| 174 |
<a href="/cgi-bin/koha/opac-illrequests.pl?op=view&illrequest_id=[% request.id | uri %]" class="btn btn-primary btn-sm">View</a> |
| 175 |
</td> |
| 176 |
</tr> |
| 177 |
[% END %] |
| 178 |
</tbody> |
155 |
</tbody> |
| 179 |
</table> |
156 |
</table> |
| 180 |
[% ELSIF op == 'view' %] |
157 |
[% ELSIF op == 'view' %] |
|
Lines 340-350
Link Here
|
| 340 |
[% BLOCK jsinclude %] |
317 |
[% BLOCK jsinclude %] |
| 341 |
[% INCLUDE 'datatables.inc' %] |
318 |
[% INCLUDE 'datatables.inc' %] |
| 342 |
<script> |
319 |
<script> |
|
|
320 |
function display_extended_attribute(row, type) { |
| 321 |
var arr = $.grep(row.extended_attributes, ( x => x.type === type )); |
| 322 |
if (arr.length > 0) { |
| 323 |
return escape_str(arr[0].value); |
| 324 |
} |
| 325 |
|
| 326 |
return ''; |
| 327 |
} |
| 328 |
|
| 329 |
function display_request_status(row) { |
| 330 |
let status = row._strings.status.str; |
| 331 |
let status_alias = row._strings.status_av ? |
| 332 |
row._strings.status_av.str ? |
| 333 |
row._strings.status_av.str : |
| 334 |
row._strings.status_av.code : |
| 335 |
null; |
| 336 |
|
| 337 |
let status_label = status + (status_alias ? " <i><strong>"+status_alias+"</strong></i>" : ""); |
| 338 |
|
| 339 |
return status_label; |
| 340 |
} |
| 343 |
$("#illrequestlist").dataTable($.extend(true, {}, dataTablesDefaults, { |
341 |
$("#illrequestlist").dataTable($.extend(true, {}, dataTablesDefaults, { |
| 344 |
"columnDefs": [ |
342 |
columns: [ |
| 345 |
{ "targets": [ -1 ], "sortable": false, "searchable": false } |
343 |
{ |
|
|
344 |
data: 'ill_request_id', |
| 345 |
sortable: true, |
| 346 |
render: (data, type, row, meta) => { |
| 347 |
return data; |
| 348 |
}, |
| 349 |
}, |
| 350 |
{ |
| 351 |
data: 'author', |
| 352 |
sortable: false, |
| 353 |
render: (data, type, row, meta) => { |
| 354 |
return display_extended_attribute(row, 'author'); |
| 355 |
}, |
| 356 |
}, |
| 357 |
{ |
| 358 |
data: 'title', |
| 359 |
sortable: false, |
| 360 |
render: (data, type, row, meta) => { |
| 361 |
return display_extended_attribute(row, 'title'); |
| 362 |
}, |
| 363 |
}, |
| 364 |
{ |
| 365 |
data: 'ill_backend_id', |
| 366 |
sortable: true, |
| 367 |
render: (data, type, row, meta) => { |
| 368 |
return escape_str(data); |
| 369 |
}, |
| 370 |
}, |
| 371 |
{ |
| 372 |
data: 'type', |
| 373 |
sortable: false, |
| 374 |
render: (data, type, row, meta) => { |
| 375 |
return display_extended_attribute(row, 'type'); |
| 376 |
}, |
| 377 |
}, |
| 378 |
{ |
| 379 |
data: 'status', |
| 380 |
sortable: true, |
| 381 |
render: (data, type, row, meta) => { |
| 382 |
return display_request_status(row); |
| 383 |
}, |
| 384 |
}, |
| 385 |
{ |
| 386 |
data: 'requested_date', |
| 387 |
sortable: true, |
| 388 |
render: (data, type, row, meta) => { |
| 389 |
return $date(data); |
| 390 |
}, |
| 391 |
}, |
| 392 |
{ |
| 393 |
data: 'timestamp', |
| 394 |
sortable: true, |
| 395 |
render: (data, type, row, meta) => { |
| 396 |
return $date(data); |
| 397 |
}, |
| 398 |
}, |
| 399 |
{ |
| 400 |
data: '', |
| 401 |
sortable: false, |
| 402 |
render: (data, type, row, meta) => { |
| 403 |
return `<a href="/cgi-bin/koha/opac-illrequests.pl?op=view&illrequest_id=${row.ill_request_id}" class="btn btn-primary btn-sm">View</a>`; |
| 404 |
}, |
| 405 |
} |
| 346 |
], |
406 |
], |
| 347 |
"order": [[ 3, "desc" ]], |
407 |
"order": [[ 0, "desc" ]], |
|
|
408 |
"dom": '<"dt-info"i><"top pager"<"table_entries"lp>>tr<"bottom pager"ip>', |
| 409 |
"paging": true, |
| 410 |
"serverSide": true, |
| 411 |
"ajax": { |
| 412 |
"cache": true, |
| 413 |
"url": '/api/v1/patrons/[% logged_in_user.borrowernumber %]/ill/requests', |
| 414 |
'beforeSend': function (xhr, settings) { |
| 415 |
this._xhr = xhr; |
| 416 |
xhr.setRequestHeader('x-koha-embed', '+strings,extended_attributes'); |
| 417 |
}, |
| 418 |
"data": (data, settings) => { |
| 419 |
const order = data.order[0]; |
| 420 |
const order_by = (order.dir == 'asc' ? '+' : '-') + 'me.' + data.columns[order.column].data; |
| 421 |
const page = Math.floor(data.start / data.length) + 1; |
| 422 |
return { |
| 423 |
_page: page, |
| 424 |
_per_page: data.length, |
| 425 |
_order_by: order_by, |
| 426 |
}; |
| 427 |
}, |
| 428 |
'dataFilter': function (data, type) { |
| 429 |
const json = {data: JSON.parse(data)}; |
| 430 |
if (total = this._xhr.getResponseHeader('x-total-count')) { |
| 431 |
json.recordsTotal = total; |
| 432 |
json.recordsFiltered = total; |
| 433 |
} |
| 434 |
if (total = this._xhr.getResponseHeader('x-base-total-count')) { |
| 435 |
json.recordsTotal = total; |
| 436 |
} |
| 437 |
if (draw = this._xhr.getResponseHeader('x-koha-request-id')) { |
| 438 |
json.draw = draw; |
| 439 |
} |
| 440 |
|
| 441 |
return JSON.stringify(json); |
| 442 |
}, |
| 443 |
}, |
| 348 |
})); |
444 |
})); |
| 349 |
$("#backend-dropdown-options").removeClass("nojs"); |
445 |
$("#backend-dropdown-options").removeClass("nojs"); |
| 350 |
[% IF services_json.length > 0 %] |
446 |
[% IF services_json.length > 0 %] |