|
Lines 152-174
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> [% IF request.metadata.Author %][% request.metadata.Author | html %][% ELSE %]<span>N/A</span>[% END %] </td> |
| 161 |
<td> [% IF request.metadata.Title %][% request.metadata.Title | html %][% ELSE %]<span>N/A</span>[% END %] </td> |
| 162 |
<td>[% request.backend | html %]</td> |
| 163 |
<td> [% IF type %][% type | html %][% ELSE %]<span>N/A</span>[% END %] </td> |
| 164 |
<td>[% request.status_alias ? request.statusalias.lib_opac : request.capabilities.$status.name | html %]</td> |
| 165 |
<td data-order="[% request.placed | html %]">[% request.placed | $KohaDates %]</td> |
| 166 |
<td data-order="[% request.updated | html %]">[% request.updated | $KohaDates %]</td> |
| 167 |
<td> |
| 168 |
<a href="/cgi-bin/koha/opac-illrequests.pl?op=view&illrequest_id=[% request.id | uri %]" class="btn btn-primary btn-sm">View</a> |
| 169 |
</td> |
| 170 |
</tr> |
| 171 |
[% END %] |
| 172 |
</tbody> |
155 |
</tbody> |
| 173 |
</table> |
156 |
</table> |
| 174 |
[% ELSIF op == 'view' %] |
157 |
[% ELSIF op == 'view' %] |
|
Lines 411-420
Link Here
|
| 411 |
[% BLOCK jsinclude %] |
394 |
[% BLOCK jsinclude %] |
| 412 |
[% INCLUDE 'datatables.inc' %] |
395 |
[% INCLUDE 'datatables.inc' %] |
| 413 |
<script> |
396 |
<script> |
| 414 |
$("#illrequestlist").kohaTable({ |
397 |
function display_extended_attribute(row, type) { |
| 415 |
columnDefs: [{ targets: [-1], orderable: false, searchable: false }], |
398 |
var arr = $.grep(row.extended_attributes, ( x => x.type === type )); |
| 416 |
order: [[3, "desc"]], |
399 |
if (arr.length > 0) { |
| 417 |
}); |
400 |
return escape_str(arr[0].value); |
|
|
401 |
} |
| 402 |
|
| 403 |
return ''; |
| 404 |
} |
| 405 |
|
| 406 |
function display_request_status(row) { |
| 407 |
let status = row._strings.status.str; |
| 408 |
let status_alias = row._strings.status_av ? |
| 409 |
row._strings.status_av.str ? |
| 410 |
row._strings.status_av.str : |
| 411 |
row._strings.status_av.code : |
| 412 |
null; |
| 413 |
|
| 414 |
let status_label = status + (status_alias ? " <i><strong>"+status_alias+"</strong></i>" : ""); |
| 415 |
|
| 416 |
return status_label; |
| 417 |
} |
| 418 |
$("#illrequestlist").dataTable($.extend(true, {}, dataTablesDefaults, { |
| 419 |
columns: [ |
| 420 |
{ |
| 421 |
data: 'ill_request_id', |
| 422 |
sortable: true, |
| 423 |
render: (data, type, row, meta) => { |
| 424 |
return data; |
| 425 |
}, |
| 426 |
}, |
| 427 |
{ |
| 428 |
data: 'author', |
| 429 |
sortable: false, |
| 430 |
render: (data, type, row, meta) => { |
| 431 |
return display_extended_attribute(row, 'author'); |
| 432 |
}, |
| 433 |
}, |
| 434 |
{ |
| 435 |
data: 'title', |
| 436 |
sortable: false, |
| 437 |
render: (data, type, row, meta) => { |
| 438 |
return display_extended_attribute(row, 'title'); |
| 439 |
}, |
| 440 |
}, |
| 441 |
{ |
| 442 |
data: 'ill_backend_id', |
| 443 |
sortable: true, |
| 444 |
render: (data, type, row, meta) => { |
| 445 |
return escape_str(data); |
| 446 |
}, |
| 447 |
}, |
| 448 |
{ |
| 449 |
data: 'type', |
| 450 |
sortable: false, |
| 451 |
render: (data, type, row, meta) => { |
| 452 |
return display_extended_attribute(row, 'type'); |
| 453 |
}, |
| 454 |
}, |
| 455 |
{ |
| 456 |
data: 'status', |
| 457 |
sortable: true, |
| 458 |
render: (data, type, row, meta) => { |
| 459 |
return display_request_status(row); |
| 460 |
}, |
| 461 |
}, |
| 462 |
{ |
| 463 |
data: 'requested_date', |
| 464 |
sortable: true, |
| 465 |
render: (data, type, row, meta) => { |
| 466 |
return $date(data); |
| 467 |
}, |
| 468 |
}, |
| 469 |
{ |
| 470 |
data: 'timestamp', |
| 471 |
sortable: true, |
| 472 |
render: (data, type, row, meta) => { |
| 473 |
return $date(data); |
| 474 |
}, |
| 475 |
}, |
| 476 |
{ |
| 477 |
data: '', |
| 478 |
sortable: false, |
| 479 |
render: (data, type, row, meta) => { |
| 480 |
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>`; |
| 481 |
}, |
| 482 |
} |
| 483 |
], |
| 484 |
"order": [[ 0, "desc" ]], |
| 485 |
"dom": '<"dt-info"i><"top pager"<"table_entries"lp>>tr<"bottom pager"ip>', |
| 486 |
"paging": true, |
| 487 |
"serverSide": true, |
| 488 |
"ajax": { |
| 489 |
"cache": true, |
| 490 |
"url": '/api/v1/patrons/[% logged_in_user.borrowernumber %]/ill/requests', |
| 491 |
'beforeSend': function (xhr, settings) { |
| 492 |
this._xhr = xhr; |
| 493 |
xhr.setRequestHeader('x-koha-embed', '+strings,extended_attributes'); |
| 494 |
}, |
| 495 |
"data": (data, settings) => { |
| 496 |
const order = data.order[0]; |
| 497 |
const order_by = (order.dir == 'asc' ? '+' : '-') + 'me.' + data.columns[order.column].data; |
| 498 |
const page = Math.floor(data.start / data.length) + 1; |
| 499 |
return { |
| 500 |
_page: page, |
| 501 |
_per_page: data.length, |
| 502 |
_order_by: order_by, |
| 503 |
}; |
| 504 |
}, |
| 505 |
'dataFilter': function (data, type) { |
| 506 |
const json = {data: JSON.parse(data)}; |
| 507 |
if (total = this._xhr.getResponseHeader('x-total-count')) { |
| 508 |
json.recordsTotal = total; |
| 509 |
json.recordsFiltered = total; |
| 510 |
} |
| 511 |
if (total = this._xhr.getResponseHeader('x-base-total-count')) { |
| 512 |
json.recordsTotal = total; |
| 513 |
} |
| 514 |
if (draw = this._xhr.getResponseHeader('x-koha-request-id')) { |
| 515 |
json.draw = draw; |
| 516 |
} |
| 517 |
|
| 518 |
return JSON.stringify(json); |
| 519 |
}, |
| 520 |
}, |
| 521 |
})); |
| 418 |
$("#backend-dropdown-options").removeClass("nojs"); |
522 |
$("#backend-dropdown-options").removeClass("nojs"); |
| 419 |
[% IF services_json.length > 0 %] |
523 |
[% IF services_json.length > 0 %] |
| 420 |
var services = [% services_json | $raw %]; |
524 |
var services = [% services_json | $raw %]; |