Lines 465-481
function LoadIssuesTable() {
Link Here
|
465 |
} |
465 |
} |
466 |
} |
466 |
} |
467 |
|
467 |
|
468 |
var loadIssuesTableDelayTimeoutId; |
468 |
function refreshReturnClaimsTable(){ |
469 |
var barcodefield = $("#barcode"); |
469 |
const table = $('#return-claims-table'); |
|
|
470 |
if ($.fn.dataTable.isDataTable(table)) { |
471 |
table.DataTable().ajax.reload(); |
472 |
} else { |
473 |
loadReturnClaimsTable(); |
474 |
} |
475 |
} |
476 |
|
477 |
function loadReturnClaimsTable() { |
478 |
if ( ! returnClaimsTable ) { |
479 |
returnClaimsTable = $("#return-claims-table").dataTable({ |
480 |
"autoWidth": false, |
481 |
"dom": "rt", |
482 |
"order": [], |
483 |
"columnDefs": [ |
484 |
{ "orderable": false, "searchable": false, "targets": ['NoSort'] }, |
485 |
{ "type": "anti-the", "targets": ["anti-the"] }, |
486 |
], |
487 |
"columns": [ |
488 |
{ |
489 |
"data": "id", |
490 |
"visible": false, |
491 |
}, |
492 |
{ |
493 |
"data": function (oObj) { |
494 |
if (oObj.resolution) { |
495 |
return "is_resolved"; |
496 |
} else { |
497 |
return "is_unresolved"; |
498 |
} |
499 |
}, |
500 |
"visible": false, |
501 |
}, |
502 |
{ |
503 |
"data": function ( oObj ) { |
504 |
let title = '<a class="return-claim-title strong" href="/cgi-bin/koha/catalogue/detail.pl?biblionumber=' + oObj.biblionumber + '">' |
505 |
+ oObj.title |
506 |
+ ( oObj.subtitle ? " " + oObj.subtitle : "" ) |
507 |
+ ( oObj.enumchron || "" ) |
508 |
+ '</a>'; |
509 |
if ( oObj.author ) { |
510 |
title += ' by ' + oObj.author; |
511 |
} |
512 |
title += ' <a href="/cgi-bin/koha/catalogue/moredetail.pl?biblionumber=' |
513 |
+ oObj.biblionumber |
514 |
+ '&itemnumber=' |
515 |
+ oObj.itemnumber |
516 |
+ '">' |
517 |
+ (oObj.barcode ? oObj.barcode.escapeHtml() : "") |
518 |
+ '</a>'; |
519 |
|
520 |
return title; |
521 |
} |
522 |
}, |
523 |
{ |
524 |
"className": "return-claim-notes-td", |
525 |
"data": function ( oObj ) { |
526 |
let notes = '<span id="return-claim-notes-static-' + oObj.id + '" class="return-claim-notes" data-return-claim-id="' + oObj.id + '">'; |
527 |
if ( oObj.notes ) { |
528 |
notes += oObj.notes; |
529 |
} |
530 |
notes += '</span>'; |
531 |
notes += '<i style="float:right" class="fa-solid fa-pen-to-square" title="' + __("Double click to edit") + '"></i>'; |
532 |
return notes; |
533 |
} |
534 |
}, |
535 |
{ |
536 |
"data": "created_on", |
537 |
"visible": false, |
538 |
}, |
539 |
{ |
540 |
"orderData": 4, |
541 |
"data": function ( oObj ) { |
542 |
if ( oObj.created_on ) { |
543 |
return $date(oObj.created_on, { no_tz_adjust: true });; |
544 |
} else { |
545 |
return ""; |
546 |
} |
547 |
} |
548 |
}, |
549 |
{ |
550 |
"data": "updated_on", |
551 |
"visible": false, |
552 |
}, |
553 |
{ |
554 |
"orderData": 6, |
555 |
"data": function ( oObj ) { |
556 |
if ( oObj.updated_on ) { |
557 |
return $date(oObj.updated_on, { no_tz_adjust: true }); |
558 |
} else { |
559 |
return ""; |
560 |
} |
561 |
} |
562 |
}, |
563 |
{ |
564 |
"data": function ( oObj ) { |
565 |
if ( ! oObj.resolution ) return ""; |
566 |
|
567 |
let desc = '<strong>' + oObj.resolution_data.lib + '</strong> <i>('; |
568 |
if (oObj.resolved_by_data) desc += '<a href="/cgi-bin/koha/circ/circulation.pl?borrowernumber=' + oObj.resolved_by_data.borrowernumber + '">' + ( oObj.resolved_by_data.firstname || "" ) + " " + ( oObj.resolved_by_data.surname || "" ) + '</a>'; |
569 |
desc += ', ' + oObj.resolved_on + ')</i>'; |
570 |
return desc; |
571 |
} |
572 |
}, |
573 |
{ |
574 |
"data": function ( oObj ) { |
575 |
let delete_html = oObj.resolved_on |
576 |
? '<li><a href="#" class="return-claim-tools-delete" data-return-claim-id="' + oObj.id + '"><i class="fa fa-trash-can"></i> ' + __("Delete") + '</a></li>' |
577 |
: ""; |
578 |
let resolve_html = ! oObj.resolution |
579 |
? '<li><a href="#" class="return-claim-tools-resolve" data-return-claim-id="' + oObj.id + '" data-current-lost-status="' + escape_str(oObj.itemlost) + '"><i class="fa fa-check-square"></i> ' + __("Resolve") + '</a></li>' |
580 |
: ""; |
581 |
|
582 |
return '<div class="btn-group">' |
583 |
+ ' <button type="button" class="btn btn-default btn-xs dropdown-toggle" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">' |
584 |
+ __("Actions") + ' <span class="caret"></span>' |
585 |
+ ' </button>' |
586 |
+ ' <ul class="dropdown-menu">' |
587 |
+ ' <li><a href="#" class="return-claim-tools-editnotes" data-return-claim-id="' + oObj.id + '"><i class="fa-solid fa-pencil" aria-hidden="true"></i> ' + __("Edit notes") + '</a></li>' |
588 |
+ resolve_html |
589 |
+ delete_html |
590 |
+ ' </ul>' |
591 |
+ ' </div>'; |
592 |
} |
593 |
}, |
594 |
], |
595 |
"paging": false, |
596 |
"processing": true, |
597 |
"serverSide": false, |
598 |
"sAjaxSource": '/cgi-bin/koha/svc/return_claims', |
599 |
"fnServerData": function ( sSource, aoData, fnCallback ) { |
600 |
aoData.push( { "name": "borrowernumber", "value": borrowernumber } ); |
601 |
|
602 |
$.getJSON( sSource, aoData, function (json) { |
603 |
let resolved = Number( json.resolved ) || 0; |
604 |
let unresolved = Number( json.unresolved ) || 0; |
605 |
let warningThreshold = $("#return-claims-count-unresolved").data("warning"); |
606 |
|
607 |
refreshTabCount( $('#return-claims-count-unresolved'), unresolved ); |
608 |
|
609 |
if( warningThreshold !== '' && ( ( resolved + unresolved ) > Number( warningThreshold ) ) ){ |
610 |
refreshTabCount( $('#return-claims-count-resolved'), resolved ); |
611 |
$("#return-claims-count").attr("class", "label label-warning"); |
612 |
} else { |
613 |
$("#return-claims-count").attr("class", "label label-info"); |
614 |
} |
615 |
fnCallback(json) |
616 |
} ); |
617 |
}, |
618 |
"search": { "search": "is_unresolved" }, |
619 |
"footerCallback": function (row, data, start, end, display) { |
620 |
var api = this.api(); |
621 |
// Total over all pages |
622 |
var colData = api.column(1).data(); |
623 |
var is_unresolved = 0; |
624 |
var is_resolved = 0; |
625 |
colData.each(function( index, value ){ |
626 |
if( index == "is_unresolved" ){ is_unresolved++; } |
627 |
if (index == "is_resolved") { is_resolved++; } |
628 |
}); |
629 |
// Update footer |
630 |
$("#return-claims-controls").html( showClaimFilter( is_unresolved, is_resolved ) ) |
631 |
} |
632 |
}); |
633 |
} |
634 |
} |
470 |
|
635 |
|
471 |
$('#issues-table-load-now-button').click(function(){ |
636 |
function showClaimFilter( is_unresolved, is_resolved ){ |
472 |
if ( loadIssuesTableDelayTimeoutId ) clearTimeout(loadIssuesTableDelayTimeoutId); |
637 |
var showAll, showUnresolved; |
473 |
LoadIssuesTable(); |
638 |
var total = Number( is_unresolved ) + Number( is_resolved ); |
474 |
barcodefield.focus(); |
639 |
if( total > 0 ){ |
|
|
640 |
showAll = __nx("Show 1 claim", "Show all {count} claims", total, { count: total }); |
641 |
} else { |
642 |
showAll = ""; |
643 |
} |
644 |
if( is_unresolved > 0 ){ |
645 |
showUnresolved = __nx("Show 1 unresolved claim", "Show {count} unresolved claims", is_unresolved, { count: is_unresolved }) |
646 |
} else { |
647 |
showUnresolved = ""; |
648 |
} |
649 |
$("#show_all_claims").html( showAll ); |
650 |
$("#show_unresolved_claims").html( showUnresolved ); |
651 |
} |
652 |
|
653 |
function addToList() { |
654 |
if( CAN_user_tools_manage_patron_lists ){ |
655 |
var list_id = $("#add_to_patron_list_id_select").val(); |
656 |
$('#pat_lists_panel').text(_("Loading...")); |
657 |
$("body").css("cursor", "progress"); |
658 |
$('#pat_lists_panel').load('/cgi-bin/koha/patron_lists/patron-lists-tab.pl?borrowernumber=' + borrowernumber + '&patron_list_id=' + list_id + '&patrons_to_add=' + cardnumber, function() { |
659 |
refreshTabCount( $("#patron-lists-count"), $("#table_inlists tbody tr").length ); |
660 |
$("body").css("cursor", "default"); |
661 |
}); |
662 |
} |
663 |
return false; |
664 |
} |
665 |
|
666 |
function removeFromList( list_id, patron_list_patron_id ) { |
667 |
if( CAN_user_tools_manage_patron_lists ){ |
668 |
$('#pat_lists_panel').text(_("Loading...")); |
669 |
$("body").css("cursor", "progress"); |
670 |
$('#pat_lists_panel').load('/cgi-bin/koha/patron_lists/patron-lists-tab.pl?borrowernumber=' + borrowernumber + '&patron_list_id=' + list_id + '&patrons_to_remove=' + patron_list_patron_id, function() { |
671 |
refreshTabCount( $("#patron-lists-count"), $("#table_inlists tbody tr").length ); |
672 |
$("body").css("cursor", "default"); |
673 |
}); |
674 |
} |
475 |
return false; |
675 |
return false; |
476 |
}); |
676 |
} |
|
|
677 |
|
678 |
function refreshTabCount( container, num ){ |
679 |
if( num > 0 ){ |
680 |
container.text( num ); |
681 |
} else { |
682 |
container.text( "" ); |
683 |
} |
684 |
} |
685 |
|
686 |
var loadIssuesTableDelayTimeoutId; |
687 |
var barcodefield = $("#barcode"); |
688 |
var returnClaimsTable; |
477 |
|
689 |
|
478 |
$(document).ready(function() { |
690 |
$(document).ready(function() { |
|
|
691 |
$('#issues-table-load-now-button').click(function(){ |
692 |
if ( loadIssuesTableDelayTimeoutId ) clearTimeout(loadIssuesTableDelayTimeoutId); |
693 |
LoadIssuesTable(); |
694 |
barcodefield.focus(); |
695 |
return false; |
696 |
}); |
479 |
|
697 |
|
480 |
var onHoldDueDateSet = false; |
698 |
var onHoldDueDateSet = false; |
481 |
|
699 |
|
Lines 995-1199
$(document).ready(function() {
Link Here
|
995 |
}); |
1213 |
}); |
996 |
|
1214 |
|
997 |
// Don't load return claims table unless its tab is shown |
1215 |
// Don't load return claims table unless its tab is shown |
998 |
var returnClaimsTable; |
|
|
999 |
$("#return-claims-tab").on('shown.bs.tab', function() { |
1216 |
$("#return-claims-tab").on('shown.bs.tab', function() { |
1000 |
refreshReturnClaimsTable(); |
1217 |
refreshReturnClaimsTable(); |
1001 |
}); |
1218 |
}); |
1002 |
|
1219 |
|
1003 |
function refreshReturnClaimsTable(){ |
|
|
1004 |
const table = $('#return-claims-table'); |
1005 |
if ($.fn.dataTable.isDataTable(table)) { |
1006 |
table.DataTable().ajax.reload(); |
1007 |
} else { |
1008 |
loadReturnClaimsTable(); |
1009 |
} |
1010 |
} |
1011 |
function loadReturnClaimsTable() { |
1012 |
if ( ! returnClaimsTable ) { |
1013 |
returnClaimsTable = $("#return-claims-table").dataTable({ |
1014 |
"autoWidth": false, |
1015 |
"dom": "rt", |
1016 |
"order": [], |
1017 |
"columnDefs": [ |
1018 |
{ "orderable": false, "searchable": false, "targets": ['NoSort'] }, |
1019 |
{ "type": "anti-the", "targets": ["anti-the"] }, |
1020 |
], |
1021 |
"columns": [ |
1022 |
{ |
1023 |
"data": "id", |
1024 |
"visible": false, |
1025 |
}, |
1026 |
{ |
1027 |
"data": function (oObj) { |
1028 |
if (oObj.resolution) { |
1029 |
return "is_resolved"; |
1030 |
} else { |
1031 |
return "is_unresolved"; |
1032 |
} |
1033 |
}, |
1034 |
"visible": false, |
1035 |
}, |
1036 |
{ |
1037 |
"data": function ( oObj ) { |
1038 |
let title = '<a class="return-claim-title strong" href="/cgi-bin/koha/catalogue/detail.pl?biblionumber=' + oObj.biblionumber + '">' |
1039 |
+ oObj.title |
1040 |
+ ( oObj.subtitle ? " " + oObj.subtitle : "" ) |
1041 |
+ ( oObj.enumchron || "" ) |
1042 |
+ '</a>'; |
1043 |
if ( oObj.author ) { |
1044 |
title += ' by ' + oObj.author; |
1045 |
} |
1046 |
title += ' <a href="/cgi-bin/koha/catalogue/moredetail.pl?biblionumber=' |
1047 |
+ oObj.biblionumber |
1048 |
+ '&itemnumber=' |
1049 |
+ oObj.itemnumber |
1050 |
+ '">' |
1051 |
+ (oObj.barcode ? oObj.barcode.escapeHtml() : "") |
1052 |
+ '</a>'; |
1053 |
|
1054 |
return title; |
1055 |
} |
1056 |
}, |
1057 |
{ |
1058 |
"className": "return-claim-notes-td", |
1059 |
"data": function ( oObj ) { |
1060 |
let notes = '<span id="return-claim-notes-static-' + oObj.id + '" class="return-claim-notes" data-return-claim-id="' + oObj.id + '">'; |
1061 |
if ( oObj.notes ) { |
1062 |
notes += oObj.notes; |
1063 |
} |
1064 |
notes += '</span>'; |
1065 |
notes += '<i style="float:right" class="fa-solid fa-pen-to-square" title="' + __("Double click to edit") + '"></i>'; |
1066 |
return notes; |
1067 |
} |
1068 |
}, |
1069 |
{ |
1070 |
"data": "created_on", |
1071 |
"visible": false, |
1072 |
}, |
1073 |
{ |
1074 |
"orderData": 4, |
1075 |
"data": function ( oObj ) { |
1076 |
if ( oObj.created_on ) { |
1077 |
return $date(oObj.created_on, { no_tz_adjust: true });; |
1078 |
} else { |
1079 |
return ""; |
1080 |
} |
1081 |
} |
1082 |
}, |
1083 |
{ |
1084 |
"data": "updated_on", |
1085 |
"visible": false, |
1086 |
}, |
1087 |
{ |
1088 |
"orderData": 6, |
1089 |
"data": function ( oObj ) { |
1090 |
if ( oObj.updated_on ) { |
1091 |
return $date(oObj.updated_on, { no_tz_adjust: true }); |
1092 |
} else { |
1093 |
return ""; |
1094 |
} |
1095 |
} |
1096 |
}, |
1097 |
{ |
1098 |
"data": function ( oObj ) { |
1099 |
if ( ! oObj.resolution ) return ""; |
1100 |
|
1101 |
let desc = '<strong>' + oObj.resolution_data.lib + '</strong> <i>('; |
1102 |
if (oObj.resolved_by_data) desc += '<a href="/cgi-bin/koha/circ/circulation.pl?borrowernumber=' + oObj.resolved_by_data.borrowernumber + '">' + ( oObj.resolved_by_data.firstname || "" ) + " " + ( oObj.resolved_by_data.surname || "" ) + '</a>'; |
1103 |
desc += ', ' + oObj.resolved_on + ')</i>'; |
1104 |
return desc; |
1105 |
} |
1106 |
}, |
1107 |
{ |
1108 |
"data": function ( oObj ) { |
1109 |
let delete_html = oObj.resolved_on |
1110 |
? '<li><a href="#" class="return-claim-tools-delete" data-return-claim-id="' + oObj.id + '"><i class="fa fa-trash-can"></i> ' + __("Delete") + '</a></li>' |
1111 |
: ""; |
1112 |
let resolve_html = ! oObj.resolution |
1113 |
? '<li><a href="#" class="return-claim-tools-resolve" data-return-claim-id="' + oObj.id + '" data-current-lost-status="' + escape_str(oObj.itemlost) + '"><i class="fa fa-check-square"></i> ' + __("Resolve") + '</a></li>' |
1114 |
: ""; |
1115 |
|
1116 |
return '<div class="btn-group">' |
1117 |
+ ' <button type="button" class="btn btn-default btn-xs dropdown-toggle" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">' |
1118 |
+ __("Actions") + ' <span class="caret"></span>' |
1119 |
+ ' </button>' |
1120 |
+ ' <ul class="dropdown-menu">' |
1121 |
+ ' <li><a href="#" class="return-claim-tools-editnotes" data-return-claim-id="' + oObj.id + '"><i class="fa-solid fa-pencil" aria-hidden="true"></i> ' + __("Edit notes") + '</a></li>' |
1122 |
+ resolve_html |
1123 |
+ delete_html |
1124 |
+ ' </ul>' |
1125 |
+ ' </div>'; |
1126 |
} |
1127 |
}, |
1128 |
], |
1129 |
"paging": false, |
1130 |
"processing": true, |
1131 |
"serverSide": false, |
1132 |
"sAjaxSource": '/cgi-bin/koha/svc/return_claims', |
1133 |
"fnServerData": function ( sSource, aoData, fnCallback ) { |
1134 |
aoData.push( { "name": "borrowernumber", "value": borrowernumber } ); |
1135 |
|
1136 |
$.getJSON( sSource, aoData, function (json) { |
1137 |
let resolved = json.resolved; |
1138 |
let unresolved = json.unresolved; |
1139 |
|
1140 |
if ( resolved > 0 ) { |
1141 |
$('#return-claims-count-resolved').text(resolved) |
1142 |
.removeClass('label-default') |
1143 |
.addClass('label-success'); |
1144 |
} else { |
1145 |
$('#return-claims-count-resolved').text(resolved) |
1146 |
.removeClass('label-success') |
1147 |
.addClass('label-default'); |
1148 |
} |
1149 |
if ( unresolved > 0 ) { |
1150 |
$('#return-claims-count-unresolved').text(unresolved) |
1151 |
.removeClass('label-default') |
1152 |
.addClass('label-warning'); |
1153 |
} else { |
1154 |
$('#return-claims-count-unresolved').text(unresolved) |
1155 |
.removeClass('label-warning') |
1156 |
.addClass('label-default'); |
1157 |
} |
1158 |
|
1159 |
fnCallback(json) |
1160 |
} ); |
1161 |
}, |
1162 |
"search": { "search": "is_unresolved" }, |
1163 |
"footerCallback": function (row, data, start, end, display) { |
1164 |
var api = this.api(); |
1165 |
// Total over all pages |
1166 |
var colData = api.column(1).data(); |
1167 |
var is_unresolved = 0; |
1168 |
var is_resolved = 0; |
1169 |
colData.each(function( index, value ){ |
1170 |
if( index == "is_unresolved" ){ is_unresolved++; } |
1171 |
if (index == "is_resolved") { is_resolved++; } |
1172 |
}); |
1173 |
// Update footer |
1174 |
$("#return-claims-controls").html( showClaimFilter( is_unresolved, is_resolved ) ) |
1175 |
} |
1176 |
}); |
1177 |
} |
1178 |
} |
1179 |
|
1180 |
function showClaimFilter( is_unresolved, is_resolved ){ |
1181 |
var showAll, showUnresolved; |
1182 |
var total = Number( is_unresolved ) + Number( is_resolved ); |
1183 |
if( total > 0 ){ |
1184 |
showAll = __nx("Show 1 claim", "Show all {count} claims", total, { count: total }); |
1185 |
} else { |
1186 |
showAll = ""; |
1187 |
} |
1188 |
if( is_unresolved > 0 ){ |
1189 |
showUnresolved = __nx("Show 1 unresolved claim", "Show {count} unresolved claims", is_unresolved, { count: is_unresolved }) |
1190 |
} else { |
1191 |
showUnresolved = ""; |
1192 |
} |
1193 |
$("#show_all_claims").html( showAll ); |
1194 |
$("#show_unresolved_claims").html( showUnresolved ); |
1195 |
} |
1196 |
|
1197 |
$('body').on('click', '.return-claim-tools-editnotes', function() { |
1220 |
$('body').on('click', '.return-claim-tools-editnotes', function() { |
1198 |
let id = $(this).data('return-claim-id'); |
1221 |
let id = $(this).data('return-claim-id'); |
1199 |
$('#return-claim-notes-static-' + id).parent().dblclick(); |
1222 |
$('#return-claim-notes-static-' + id).parent().dblclick(); |
Lines 1276-1279
$(document).ready(function() {
Link Here
|
1276 |
$("#return-claims-table").DataTable().search("is_unresolved").draw(); |
1299 |
$("#return-claims-table").DataTable().search("is_unresolved").draw(); |
1277 |
}); |
1300 |
}); |
1278 |
|
1301 |
|
|
|
1302 |
$("body").on("click", "#add_patron_to_list", function(e){ |
1303 |
e.preventDefault(); |
1304 |
addToList(); |
1305 |
}); |
1306 |
|
1307 |
$("#table_listnopatron, #table_inlists").dataTable($.extend(true, {}, dataTablesDefaults, { |
1308 |
"columnDefs": [ |
1309 |
{ 'sortable': false, "bSearchable": false, 'targets': [ 'NoSort' ] } |
1310 |
], |
1311 |
"sPaginationType": "full" |
1312 |
})); |
1279 |
}); |
1313 |
}); |