Lines 4-9
var browser = KOHA.browser(searchid, parseInt(biblionumber, 10));
Link Here
|
4 |
browser.show(); |
4 |
browser.show(); |
5 |
|
5 |
|
6 |
$(document).ready(function(){ |
6 |
$(document).ready(function(){ |
|
|
7 |
table_settings['columns'].unshift( { cannot_be_toggled: "1" } ); |
8 |
build_itemst(false, {}); |
9 |
|
10 |
const filterContainer = document.querySelector('.show_hide_filters'); |
11 |
const showFiltersLink = filterContainer.querySelector('.show_filters'); |
12 |
const hideFiltersLink = filterContainer.querySelector('.hide_filters'); |
13 |
|
14 |
$(".show_filters").on("click",function(e){ |
15 |
e.preventDefault(); |
16 |
showFiltersLink.style.display = 'none'; |
17 |
hideFiltersLink.style.display = 'inline'; |
18 |
$("#itemst thead tr:eq(1)").remove(); |
19 |
build_itemst(true, { destroy: true }); |
20 |
}); |
21 |
|
22 |
$(".hide_filters").on("click",function(e){ |
23 |
e.preventDefault(); |
24 |
showFiltersLink.style.display = 'inline'; |
25 |
hideFiltersLink.style.display = 'none'; |
26 |
$("#itemst thead tr:eq(1)").remove(); |
27 |
build_itemst(false, { destroy: true }); |
28 |
}); |
29 |
|
30 |
// Build the filter dropdowns |
31 |
const libraries_filters = all_libraries.map(e => { |
32 |
e["_id"] = e["branchcode"]; |
33 |
e["_str"] = e["branchname"]; |
34 |
return e; |
35 |
}); |
36 |
const libraries_names = new Map(all_libraries.map( l => [l.branchcode, l.branchname] )); |
37 |
|
38 |
const item_types_filters = all_item_types.map(e => { |
39 |
e["_id"] = e["itemtype"]; |
40 |
e["_str"] = e["translated_description"]; |
41 |
return e; |
42 |
}); |
43 |
|
44 |
const damaged_filters = all_damaged_statuses.map(e => { |
45 |
e["_id"] = e["authorised_value"]; |
46 |
e["_str"] = e["lib"]; |
47 |
return e; |
48 |
}); |
49 |
|
50 |
const lost_filters = all_lost_statuses.map(e => { |
51 |
e["_id"] = e["authorised_value"]; |
52 |
e["_str"] = e["lib"]; |
53 |
return e; |
54 |
}); |
55 |
|
56 |
const stack_filters = all_stack.map(e => { |
57 |
e["_id"] = e["authorised_value"]; |
58 |
e["_str"] = e["lib"]; |
59 |
return e; |
60 |
}); |
61 |
|
62 |
const ccode_filters = all_collection_codes.map(e => { |
63 |
e["_id"] = e["authorised_value"]; |
64 |
e["_str"] = e["lib"]; |
65 |
return e; |
66 |
}); |
67 |
|
68 |
const shelving_location_filters = all_shelivng_locations.map(e => { |
69 |
e["_id"] = e["authorised_value"]; |
70 |
e["_str"] = e["lib"]; |
71 |
return e; |
72 |
}); |
73 |
|
74 |
const not_for_loan_filters = all_not_for_loan_statuses.map(e => { |
75 |
e["_id"] = e["authorised_value"]; |
76 |
e["_str"] = e["lib"]; |
77 |
return e; |
78 |
}); |
79 |
|
80 |
const withdrawn_filters = all_withdrawn.map(e => { |
81 |
e["_id"] = e["authorised_value"]; |
82 |
e["_str"] = e["lib"]; |
83 |
return e; |
84 |
}); |
85 |
|
86 |
|
87 |
const restricted_filters = all_restricted_statuses.map(e => { |
88 |
e["_id"] = e["authorised_value"]; |
89 |
e["_str"] = e["lib"]; |
90 |
return e; |
91 |
}); |
92 |
|
93 |
const class_sources_filters = all_class_sources.map(e => { |
94 |
e["_id"] = e["cn_source"]; |
95 |
e["_str"] = e["description"]; |
96 |
return e; |
97 |
}); |
7 |
|
98 |
|
8 |
// Remove the onclick event defined in browser.js, |
99 |
// Remove the onclick event defined in browser.js, |
9 |
// otherwise the deletion confirmation will not work correctly |
100 |
// otherwise the deletion confirmation will not work correctly |
Lines 14-36
$(document).ready(function(){
Link Here
|
14 |
} |
105 |
} |
15 |
|
106 |
|
16 |
$("fieldset.rows input, fieldset.rows select").addClass("noEnterSubmit"); |
107 |
$("fieldset.rows input, fieldset.rows select").addClass("noEnterSubmit"); |
17 |
/* Inline edit/delete links */ |
|
|
18 |
var biblionumber = $("input[name='biblionumber']").val(); |
108 |
var biblionumber = $("input[name='biblionumber']").val(); |
19 |
$("tr.editable").each(function(){ |
|
|
20 |
$(this).find("td:not(:first)").on('click', function(){ |
21 |
var rowid = $(this).parent().attr("id"); |
22 |
var num_rowid = rowid.replace("row",""); |
23 |
$(".linktools").remove(); |
24 |
var edit_link = $('<a href="/cgi-bin/koha/cataloguing/additem.pl?op=edititem&frameworkcode=' + frameworkcode + '&biblionumber=' + biblionumber + '&itemnumber=' + num_rowid + '&searchid=' + searchid + '#edititem"></a>'); |
25 |
$(edit_link).text( LABEL_EDIT_ITEM ); |
26 |
var delete_link = $('<a class="delete" data-item="'+num_rowid+'" href="#"></a>'); |
27 |
$(delete_link).text( LABEL_DELETE_ITEM ); |
28 |
var tools_node = $('<span class="linktools"></span>'); |
29 |
$(tools_node).append(edit_link); |
30 |
$(tools_node).append(delete_link); |
31 |
$(this).append(tools_node); |
32 |
}); |
33 |
}); |
34 |
|
109 |
|
35 |
$("#addnewitem").click(function(){ |
110 |
$("#addnewitem").click(function(){ |
36 |
if ( confirm( MSG_CONFIRM_ADD_ITEM ) ){ |
111 |
if ( confirm( MSG_CONFIRM_ADD_ITEM ) ){ |
Lines 38-53
$(document).ready(function(){
Link Here
|
38 |
} |
113 |
} |
39 |
}); |
114 |
}); |
40 |
|
115 |
|
41 |
// Skip the first column |
|
|
42 |
table_settings['columns'].unshift( { cannot_be_toggled: "1" } ); |
43 |
|
44 |
var itemst = KohaTable("itemst", { |
45 |
"paging": false, |
46 |
"info": false, |
47 |
"autoWidth": false, |
48 |
"bKohaColumnsUseNames": true |
49 |
}, table_settings); |
50 |
|
51 |
var multiCopyControl = $("#add_multiple_copies_span"); |
116 |
var multiCopyControl = $("#add_multiple_copies_span"); |
52 |
var addMultipleBlock = $("#addmultiple"); |
117 |
var addMultipleBlock = $("#addmultiple"); |
53 |
var addSingleBlock = $("#addsingle"); |
118 |
var addSingleBlock = $("#addsingle"); |
Lines 203-205
function Dopop(link,i) {
Link Here
|
203 |
var defaultvalue=document.forms[0].field_value[i].value; |
268 |
var defaultvalue=document.forms[0].field_value[i].value; |
204 |
var newin=window.open(link+"&result=" + defaultvalue,"valuebuilder",'width=500,height=400,toolbar=false,scrollbars=yes'); |
269 |
var newin=window.open(link+"&result=" + defaultvalue,"valuebuilder",'width=500,height=400,toolbar=false,scrollbars=yes'); |
205 |
} |
270 |
} |
206 |
- |
271 |
|
|
|
272 |
function build_itemst(show_filters, dt_options) { |
273 |
|
274 |
if ( dt_options && dt_options.hasOwnProperty('destroy') ) { |
275 |
let table_id = "#itemst"; |
276 |
if( $.fn.dataTable.isDataTable(table_id) ) { |
277 |
$(table_id).DataTable().destroy(); |
278 |
} |
279 |
dt_options['destroy'] = null; |
280 |
} |
281 |
|
282 |
// assign positions for the filter dropdowns |
283 |
let default_filters = {}; |
284 |
var offset = 4; |
285 |
let filters_options = { |
286 |
[offset] : () => all_libraries, |
287 |
[offset+6] : () => all_stack, |
288 |
[offset+7] : () => all_not_for_loan_statuses, |
289 |
[offset+8] : () => all_damaged_statuses, |
290 |
[offset+9] : () => all_lost_statuses, |
291 |
[offset+10] : () => all_withdrawn, |
292 |
[offset+13] : () => all_restricted_statuses, |
293 |
[offset+16] : () => all_libraries, |
294 |
[offset+18] : () => all_shelivng_locations, |
295 |
[offset+20] : () => all_class_sources, |
296 |
[offset+21] : () => all_collection_codes, |
297 |
[offset+24] : () => all_item_types, |
298 |
}; |
299 |
|
300 |
var biblionumber = $("input[name='biblionumber']").val(); |
301 |
var items_table_url = '/api/v1/biblios/' + biblionumber + '/items?'; |
302 |
var items_table = $("#itemst").kohaTable({ |
303 |
ajax: { |
304 |
url: items_table_url |
305 |
}, |
306 |
order: [], |
307 |
embed: ["+strings"], |
308 |
autoWidth: false, |
309 |
columns: [ |
310 |
{ |
311 |
data: function(row, type, val, meta) { |
312 |
let nodes = ''; |
313 |
|
314 |
let can_be_edited = !(is_independent_branches && row.home_library_id != logged_in_branchname); |
315 |
if (can_be_edited) { |
316 |
nodes += '<td>' |
317 |
nodes += '<div class="btn-group dropup">'; |
318 |
nodes += '<a class="btn btn-default btn-xs dropdown-toggle" id="itemactions' + row.item_id + '" role="button" data-toggle="dropdown" href="#">'; |
319 |
nodes += 'Actions <b class="caret"></b>'; |
320 |
nodes += '</a>'; |
321 |
nodes += '<ul class="dropdown-menu" role="menu" aria-labelledby="itemactions' + row.item_id + '">'; |
322 |
if (row.biblio_id != biblionumber) { // Host item |
323 |
nodes += '<li><a href="additem.pl?op=edititem&biblionumber=' + row.biblio_id + '&itemnumber=' + row.item_id + '#edititem">Edit in host</a> <a class="delete" href="/cgi-bin/koha/cataloguing/additem.pl?op=delinkitem&biblionumber=' + row.biblio_id + '&hostitemnumber=' + row.item_id + '&searchid=' + row.searchid + '">Delink</a></li>'; |
324 |
} else { |
325 |
if (can_edit_items_from.includes(row.home_library_id) || !can_edit_items_from.length) { |
326 |
nodes += '<li><a href="additem.pl?op=edititem&biblionumber=' + row.biblio_id + '&itemnumber=' + row.item_id + '&searchid=' + row.searchid + '#edititem">Edit</a></li>'; |
327 |
} |
328 |
nodes += '<li><a href="additem.pl?op=dupeitem&biblionumber=' + row.biblio_id + '&itemnumber=' + row.item_id + '&searchid=' + row.searchid + '#additema">Duplicate</a></li>'; |
329 |
nodes += '<li class="print_label">'; |
330 |
nodes += '<a class="submit-form-link" target="_blank" href="#" data-op="cud-add" data-number_list="' + row.item_id + '" data-number_type="itemnumber" data-method="post" data-action="/cgi-bin/koha/labels/label-edit-batch.pl" data-new_tab="true">Print label</a>'; |
331 |
nodes += '</li>'; |
332 |
if (can_edit_items_from.includes(row.home_library_id) || !can_edit_items_from.length) { |
333 |
let csrfToken = $('meta[name="csrf-token"]').attr('content'); |
334 |
nodes += '<li>'; |
335 |
nodes += '<form id="' + row.item_id + '-delete-item-form" action="/cgi-bin/koha/cataloguing/additem.pl" method="post">'; |
336 |
nodes += '<input type="hidden" name="csrf_token" value="' + csrfToken + '" />'; |
337 |
nodes += '<input type="hidden" name="op" value="cud-delitem" />'; |
338 |
nodes += '<input type="hidden" name="biblionumber" value="' + row.biblio_id + '" />'; |
339 |
nodes += '<input type="hidden" name="itemnumber" value="' + row.item_id + '" />'; |
340 |
nodes += '<input type="hidden" name="searchid" value="' + row.searchid + '" />'; |
341 |
nodes += '</form>'; |
342 |
nodes += '<a class="delete" data-item="' + row.item_id + '" href="#">Delete</a>'; |
343 |
nodes += '</li>'; |
344 |
} |
345 |
} |
346 |
if ( opac_base_url ) { |
347 |
var href = opac_base_url + "/cgi-bin/koha/opac-detail.pl?biblionumber=" + row.biblio_id; |
348 |
nodes+= '<li class="view-in-opac"><a target="_blank" href="' + href + '">OPAC view</a></li>' |
349 |
} |
350 |
nodes += '</ul>'; |
351 |
nodes += '</div>'; |
352 |
nodes += '</td>'; |
353 |
} else { |
354 |
nodes += '<td> </td>' |
355 |
} |
356 |
return nodes; |
357 |
}, |
358 |
searchable: false, |
359 |
orderable: false, |
360 |
}, |
361 |
{ |
362 |
data: "external_id", |
363 |
searchable: true, |
364 |
orderable: true, |
365 |
render: function (data, type, row, meta) { |
366 |
if ( row.external_id != null ) { |
367 |
return '<a href="/cgi-bin/koha/catalogue/moredetail.pl?biblionumber=%s&itemnumber=%s#item%s">%s</a>'.format(row.biblio_id, row.item_id, row.item_id, row.external_id); |
368 |
} |
369 |
return ''; |
370 |
} |
371 |
}, |
372 |
{ |
373 |
data: "acquisition_date", |
374 |
searchable: true, |
375 |
orderable: true, |
376 |
render: function (data, type, row, meta) { |
377 |
return $date(row.acquisition_date); |
378 |
} |
379 |
}, |
380 |
{ |
381 |
data: "acquisition_source", |
382 |
searchable: true, |
383 |
orderable: true, |
384 |
}, |
385 |
{ |
386 |
data: "home_library_id", |
387 |
searchable: true, |
388 |
orderable: true, |
389 |
render: function (data, type, row, meta) { |
390 |
return row._strings.home_library_id ? escape_str(row._strings.home_library_id.str) : ""; |
391 |
} |
392 |
}, |
393 |
{ |
394 |
data: "purchase_price", |
395 |
searchable: true, |
396 |
orderable: true, |
397 |
}, |
398 |
{ |
399 |
data: "replacement_price", |
400 |
searchable: true, |
401 |
orderable: true, |
402 |
}, |
403 |
{ |
404 |
data: "replacement_price_date", |
405 |
searchable: true, |
406 |
orderable: true, |
407 |
render: function (data, type, row, meta) { |
408 |
return $date(row.replacement_price_date); |
409 |
} |
410 |
}, |
411 |
{ |
412 |
data: "last_checkout_date", |
413 |
searchable: true, |
414 |
orderable: true, |
415 |
render: function (data, type, row, meta) { |
416 |
return $date(row.last_checkout_date); |
417 |
} |
418 |
}, |
419 |
{ |
420 |
data: "last_seen_date", |
421 |
searchable: true, |
422 |
orderable: true, |
423 |
render: function (data, type, row, meta) { |
424 |
return $date(row.last_seen_date); |
425 |
} |
426 |
}, |
427 |
{ |
428 |
data: "stack", |
429 |
searchable: true, |
430 |
orderable: true, |
431 |
render: function (data, type, row, meta) { |
432 |
return row._strings.stack ? escape_str(row._strings.stack.str) : ""; |
433 |
} |
434 |
}, |
435 |
{ |
436 |
data: "not_for_loan_status", |
437 |
searchable: true, |
438 |
orderable: true, |
439 |
render: function (data, type, row, meta) { |
440 |
return row._strings.not_for_loan_status ? escape_str(row._strings.not_for_loan_status.str) : ""; |
441 |
} |
442 |
}, |
443 |
{ |
444 |
data: "damaged_status", |
445 |
searchable: true, |
446 |
orderable: true, |
447 |
render: function (data, type, row, meta) { |
448 |
return row._strings.damaged_status ? escape_str(row._strings.damaged_status.str) : ""; |
449 |
} |
450 |
}, |
451 |
{ |
452 |
data: "lost_status", |
453 |
searchable: true, |
454 |
orderable: true, |
455 |
render: function (data, type, row, meta) { |
456 |
return row._strings.lost_status ? escape_str(row._strings.lost_status.str) : ""; |
457 |
} |
458 |
}, |
459 |
{ |
460 |
data: "withdrawn", |
461 |
searchable: true, |
462 |
orderable: true, |
463 |
render: function (data, type, row, meta) { |
464 |
return row._strings.withdrawn ? escape_str(row._strings.withdrawn.str) : ""; |
465 |
} |
466 |
}, |
467 |
{ |
468 |
data: "callnumber", |
469 |
searchable: true, |
470 |
orderable: true, |
471 |
}, |
472 |
{ |
473 |
data: "coded_location_qualifier", |
474 |
searchable: true, |
475 |
orderable: true, |
476 |
}, |
477 |
{ |
478 |
data: "restricted_status", |
479 |
searchable: true, |
480 |
orderable: true, |
481 |
render: function (data, type, row, meta) { |
482 |
return row._strings.restricted_status ? escape_str(row._strings.restricted_status.str) : ""; |
483 |
} |
484 |
}, |
485 |
{ |
486 |
data: "public_notes", |
487 |
searchable: true, |
488 |
orderable: true, |
489 |
}, |
490 |
{ |
491 |
data: "internal_notes", |
492 |
searchable: true, |
493 |
orderable: true, |
494 |
}, |
495 |
{ |
496 |
data: "holding_library_id", |
497 |
searchable: true, |
498 |
orderable: true, |
499 |
render: function (data, type, row, meta) { |
500 |
return row._strings.holding_library_id ? escape_str(row._strings.holding_library_id.str) : ""; |
501 |
} |
502 |
}, |
503 |
{ |
504 |
data: "timestamp", |
505 |
searchable: true, |
506 |
orderable: true, |
507 |
render: function (data, type, row, meta) { |
508 |
return $date(row.timestamp); |
509 |
} |
510 |
}, |
511 |
{ |
512 |
data: "location", |
513 |
searchable: true, |
514 |
orderable: true, |
515 |
render: function (data, type, row, meta) { |
516 |
return row._strings.location ? escape_str(row._strings.location.str) : ""; |
517 |
} |
518 |
|
519 |
}, |
520 |
{ |
521 |
data: "checked_out_date", |
522 |
searchable: true, |
523 |
orderable: true, |
524 |
render: function (data, type, row, meta) { |
525 |
return $date(row.checked_out_date); |
526 |
} |
527 |
}, |
528 |
{ |
529 |
data: "call_number_source", |
530 |
searchable: true, |
531 |
orderable: true, |
532 |
render: function (data, type, row, meta) { |
533 |
return row._strings.call_number_source ? escape_str(row._strings.call_number_source.str) : ""; |
534 |
} |
535 |
}, |
536 |
{ |
537 |
data: "collection_code", |
538 |
searchable: true, |
539 |
orderable: true, |
540 |
render: function (data, type, row, meta) { |
541 |
return row._strings.collection_code ? escape_str(row._strings.collection_code.str) : ""; |
542 |
} |
543 |
}, |
544 |
{ |
545 |
data: "materials_notes", |
546 |
searchable: true, |
547 |
orderable: true, |
548 |
}, |
549 |
{ |
550 |
data: "uri", |
551 |
searchable: true, |
552 |
orderable: true, |
553 |
}, |
554 |
{ |
555 |
data: "item_type_id", |
556 |
searchable: true, |
557 |
orderable: true, |
558 |
render: function (data, type, row, meta) { |
559 |
return row._strings.item_type_id ? escape_str(row._strings.item_type_id.str) : ""; |
560 |
} |
561 |
}, |
562 |
{ |
563 |
data: "serial_issue_number", |
564 |
searchable: true, |
565 |
orderable: true, |
566 |
}, |
567 |
{ |
568 |
data: "copy_number", |
569 |
searchable: true, |
570 |
orderable: true, |
571 |
}, |
572 |
{ |
573 |
data: "inventory_number", |
574 |
searchable: true, |
575 |
orderable: true, |
576 |
}, |
577 |
], |
578 |
createdRow: function(row, data, dataIndex) { |
579 |
$(row).attr('id', 'row' + data.item_id); |
580 |
|
581 |
let can_be_edited = !(is_independent_branches && data.home_library_id != logged_in_branchname); |
582 |
|
583 |
if (can_be_edited) { |
584 |
$(row).addClass('editable'); |
585 |
} |
586 |
}, |
587 |
initComplete: function( settings, json ){ |
588 |
let table = settings.oInstance.api(); |
589 |
table.columns().every(function(i){ |
590 |
let is_empty = true; |
591 |
let nodes = this.nodes(); |
592 |
nodes.each((td, ii) => { |
593 |
if ( $(td).html() !== '' ) { |
594 |
is_empty = false; |
595 |
return; |
596 |
} |
597 |
}); |
598 |
if ( is_empty ) { |
599 |
table.columns(i).visible(false); |
600 |
} |
601 |
}); |
602 |
|
603 |
}, |
604 |
drawCallback: function(settings){ |
605 |
|
606 |
if (!show_filters && settings._iRecordsDisplay == settings._iRecordsTotal && settings._iDisplayLength >= settings._iRecordsDisplay){ |
607 |
let container = $(this).parent(); |
608 |
container.find(".dt-info").remove(); |
609 |
container.find(".table_entries").remove(); |
610 |
container.find(".dataTables_filter").remove(); |
611 |
container.find(".dt_button_clear_filter").remove(); |
612 |
container.find(".bottom.pager").remove(); |
613 |
} |
614 |
|
615 |
setupRowClickHandlers(); |
616 |
|
617 |
}, |
618 |
...dt_options, |
619 |
|
620 |
}, table_settings, show_filters, default_filters, filters_options,); |
621 |
|
622 |
return items_table; |
623 |
|
624 |
} |
625 |
|
626 |
/* Inline edit/delete links */ |
627 |
function setupRowClickHandlers() { |
628 |
$("tr.editable").each(function(){ |
629 |
$(this).find("td:not(:first)").off('click').on('click', function(){ |
630 |
$("tr.editable").removeClass('active'); |
631 |
$(this).parent().addClass('active'); |
632 |
|
633 |
var rowid = $(this).parent().attr("id"); |
634 |
var num_rowid = rowid.replace("row",""); |
635 |
$(".linktools").remove(); |
636 |
var edit_link = $('<a href="/cgi-bin/koha/cataloguing/additem.pl?op=edititem&frameworkcode=' + frameworkcode + '&biblionumber=' + biblionumber + '&itemnumber=' + num_rowid + '&searchid=' + searchid + '#edititem"></a>'); |
637 |
$(edit_link).text( LABEL_EDIT_ITEM ); |
638 |
var delete_link = $('<a class="delete" data-item="'+num_rowid+'" href="#"></a>'); |
639 |
$(delete_link).text( LABEL_DELETE_ITEM ); |
640 |
var tools_node = $('<span class="linktools"></span>'); |
641 |
$(tools_node).append(edit_link); |
642 |
$(tools_node).append(delete_link); |
643 |
$(this).append(tools_node); |
644 |
}); |
645 |
}); |
646 |
} |