|
Lines 118-124
Link Here
|
| 118 |
<div id="searchheader" class="searchheader"> |
118 |
<div id="searchheader" class="searchheader"> |
| 119 |
<a id="select_all" href="#" class="btn btn-link"><i class="fa fa-check"></i> Select all visible rows</a> |
119 |
<a id="select_all" href="#" class="btn btn-link"><i class="fa fa-check"></i> Select all visible rows</a> |
| 120 |
| <a id="clear_all" href="#" class="btn btn-link"><i class="fa fa-times"></i> Clear selections</a> |
120 |
| <a id="clear_all" href="#" class="btn btn-link"><i class="fa fa-times"></i> Clear selections</a> |
| 121 |
</div> |
121 |
<div id="table_search_selections" class="btn-group" style="display:none;"> |
|
|
122 |
<span></span> |
| 123 |
<a href="#" id="clear-row-selection"><i class="fa fa-times"></i> Clear</a> |
| 124 |
</div> |
| 125 |
</div> <!-- /#searchheader --> |
| 122 |
<h3>Holds found for: <span class="searchpattern"></span></h3> |
126 |
<h3>Holds found for: <span class="searchpattern"></span></h3> |
| 123 |
<table id="holds_to_modify"></table> |
127 |
<table id="holds_to_modify"></table> |
| 124 |
</div> <!-- /#modify_holds_results --> |
128 |
</div> <!-- /#modify_holds_results --> |
|
Lines 188-208
Link Here
|
| 188 |
let hold_ids = [% IF updated_holds %] [% updated_holds | $raw %] [% ELSE %] [] [% END %]; |
192 |
let hold_ids = [% IF updated_holds %] [% updated_holds | $raw %] [% ELSE %] [] [% END %]; |
| 189 |
|
193 |
|
| 190 |
$(document).ready(function() { |
194 |
$(document).ready(function() { |
|
|
195 |
//Empty local storage from previous selections |
| 196 |
localStorage.removeItem("holds_modify_selections"); |
| 197 |
|
| 198 |
$("#holds_to_modify").on("change", "input[type='checkbox']", function(){ |
| 199 |
var holds_modify_selections = JSON.parse(localStorage.getItem("holds_modify_selections")) || []; |
| 200 |
var hold_id = $(this).val(); |
| 201 |
if ($(this).prop("checked")) { |
| 202 |
holds_modify_selections.push($(this).val()); |
| 203 |
localStorage.setItem("holds_modify_selections", JSON.stringify(holds_modify_selections)); |
| 204 |
showHoldSelections(holds_modify_selections.length); |
| 205 |
} else { |
| 206 |
var filtered = holds_modify_selections.filter(function( value ){ |
| 207 |
return value !== hold_id; |
| 208 |
}); |
| 209 |
if( filtered.length > 0 ){ |
| 210 |
localStorage.setItem("holds_modify_selections", JSON.stringify( filtered )); |
| 211 |
holds_modify_selections = filtered; |
| 212 |
showHoldSelections( filtered.length ); |
| 213 |
} else { |
| 214 |
holds_modify_selections = []; |
| 215 |
localStorage.removeItem("holds_modify_selections"); |
| 216 |
showHoldSelections( 0 ); |
| 217 |
} |
| 218 |
} |
| 219 |
}); |
| 191 |
|
220 |
|
| 192 |
$("#select_all").click(function(e){ |
221 |
$("#select_all").on("click", function(e){ |
| 193 |
e.preventDefault(); |
222 |
e.preventDefault(); |
| 194 |
$("#holds_to_modify input[type='checkbox']").each(function(){ |
223 |
$("#holds_to_modify input[type='checkbox']").each(function(){ |
| 195 |
$(this).prop("checked", true); |
224 |
$(this).prop("checked", true).change(); |
| 196 |
}); |
225 |
}); |
| 197 |
}); |
226 |
}); |
| 198 |
|
227 |
|
| 199 |
$("#clear_all").click(function(e){ |
228 |
$("#clear_all").on("click", function(e){ |
| 200 |
e.preventDefault(); |
229 |
e.preventDefault(); |
| 201 |
$("#holds_to_modify input[type='checkbox']").each(function(){ |
230 |
$("#holds_to_modify input[type='checkbox']").each(function(){ |
| 202 |
$(this).prop("checked", false); |
231 |
$(this).prop("checked", false).change(); |
| 203 |
}); |
232 |
}); |
| 204 |
}); |
233 |
}); |
| 205 |
|
234 |
|
|
|
235 |
$("#clear-row-selection").on("click", function (e) { |
| 236 |
e.preventDefault(); |
| 237 |
$("input[type='checkbox']").prop("checked", false).change(); |
| 238 |
localStorage.removeItem("holds_modify_selections"); |
| 239 |
$("#table_search_selections").hide(); |
| 240 |
}); |
| 241 |
|
| 206 |
$('#modify_holds_form').submit(function() { |
242 |
$('#modify_holds_form').submit(function() { |
| 207 |
var modify_holds_form = $(this); |
243 |
var modify_holds_form = $(this); |
| 208 |
search_holds(modify_holds_form); |
244 |
search_holds(modify_holds_form); |
|
Lines 217-222
Link Here
|
| 217 |
$('#edit_search').hide(); |
253 |
$('#edit_search').hide(); |
| 218 |
}); |
254 |
}); |
| 219 |
|
255 |
|
|
|
256 |
function prepSelections(){ |
| 257 |
let holds_modify_selections = JSON.parse( localStorage.getItem("holds_modify_selections") ) || []; |
| 258 |
if( holds_modify_selections.length > 0 ){ |
| 259 |
showHoldSelections( holds_modify_selections.length ); |
| 260 |
$("#holds_to_modify input[type='checkbox']").each(function(){ |
| 261 |
var hold_id = $(this).val(); |
| 262 |
if( holds_modify_selections.indexOf( hold_id ) >= 0 ){ |
| 263 |
$(this).prop("checked", true ); |
| 264 |
} |
| 265 |
}); |
| 266 |
} |
| 267 |
} |
| 268 |
|
| 269 |
function showHoldSelections( number ){ |
| 270 |
if (number === 0) { |
| 271 |
$("#table_search_selections").hide(); |
| 272 |
} else { |
| 273 |
$("#table_search_selections") |
| 274 |
.show() |
| 275 |
.find("span") |
| 276 |
.text(__("Holds selected: %s").format(number)); |
| 277 |
} |
| 278 |
} |
| 279 |
|
| 220 |
function search_holds(modify_holds_form){ |
280 |
function search_holds(modify_holds_form){ |
| 221 |
var table_settings = [% TablesSettings.GetTableSettings( 'circ', 'holds', 'holds_to_modify', 'json' ) | $raw %]; |
281 |
var table_settings = [% TablesSettings.GetTableSettings( 'circ', 'holds', 'holds_to_modify', 'json' ) | $raw %]; |
| 222 |
var searchpattern = ""; |
282 |
var searchpattern = ""; |
|
Lines 308-314
Link Here
|
| 308 |
"name": "checkbox", |
368 |
"name": "checkbox", |
| 309 |
"orderable": false, |
369 |
"orderable": false, |
| 310 |
"render": function(data, type, row, meta) { |
370 |
"render": function(data, type, row, meta) { |
| 311 |
return '<input type="checkbox" name="hold_id" value="'+ encodeURIComponent(data) +'"/>' |
371 |
return '<input class="selection" type="checkbox" name="hold_id" value="'+ encodeURIComponent(data) +'"/>' |
| 312 |
} |
372 |
} |
| 313 |
}, |
373 |
}, |
| 314 |
{ |
374 |
{ |
|
Lines 372-378
Link Here
|
| 372 |
} else if( data == "W" ) { |
432 |
} else if( data == "W" ) { |
| 373 |
status = _("Waiting"); |
433 |
status = _("Waiting"); |
| 374 |
} |
434 |
} |
| 375 |
return status; |
435 |
return "<span data-found-status='" + escape_str( data ) + "'>" + status + "</span>"; |
| 376 |
} |
436 |
} |
| 377 |
}, |
437 |
}, |
| 378 |
{ |
438 |
{ |
|
Lines 411-417
Link Here
|
| 411 |
return escape_str( data ); |
471 |
return escape_str( data ); |
| 412 |
} |
472 |
} |
| 413 |
} |
473 |
} |
| 414 |
] |
474 |
], |
|
|
475 |
"drawCallback": function( settings ) { |
| 476 |
prepSelections(); |
| 477 |
}, |
| 415 |
}, table_settings, 0, filters); |
478 |
}, table_settings, 0, filters); |
| 416 |
|
479 |
|
| 417 |
$(".searchpattern").text(searchpattern); |
480 |
$(".searchpattern").text(searchpattern); |
|
Lines 439-445
Link Here
|
| 439 |
if( new_pickup_loc || new_suspend_status ){ |
502 |
if( new_pickup_loc || new_suspend_status ){ |
| 440 |
var found = false; |
503 |
var found = false; |
| 441 |
holds_checked.each(function(){ |
504 |
holds_checked.each(function(){ |
| 442 |
if($(this).parents("tr").children(".found_status").html() !== "No status"){ |
505 |
if($(this).parents("tr").children(".found_status").children("span").data("found-status")){ |
| 443 |
e.preventDefault(); |
506 |
e.preventDefault(); |
| 444 |
found = true; |
507 |
found = true; |
| 445 |
} |
508 |
} |
|
Lines 468-598
Link Here
|
| 468 |
|
531 |
|
| 469 |
//Modified holds table |
532 |
//Modified holds table |
| 470 |
var table_settings = [% TablesSettings.GetTableSettings( 'circ', 'holds', 'modified_holds', 'json' ) | $raw %]; |
533 |
var table_settings = [% TablesSettings.GetTableSettings( 'circ', 'holds', 'modified_holds', 'json' ) | $raw %]; |
| 471 |
var filters = { |
534 |
var filters = { |
| 472 |
"me.hold_id": function(){ |
535 |
"me.hold_id": function(){ |
| 473 |
return {"-in": hold_ids}; |
536 |
return {"-in": hold_ids}; |
| 474 |
} |
|
|
| 475 |
} |
537 |
} |
|
|
538 |
} |
| 476 |
|
539 |
|
| 477 |
var holds_modified_table = $("#modified_holds").kohaTable({ |
540 |
var holds_modified_table = $("#modified_holds").kohaTable({ |
| 478 |
"ajax": { |
541 |
"ajax": { |
| 479 |
"url": "/api/v1/holds" |
542 |
"url": "/api/v1/holds" |
|
|
543 |
}, |
| 544 |
"embed": [ |
| 545 |
"biblio", |
| 546 |
"item", |
| 547 |
"pickup_library", |
| 548 |
"patron" |
| 549 |
], |
| 550 |
"destroy": true, |
| 551 |
"autoWidth": false, |
| 552 |
"processing": true, |
| 553 |
"columns": [ |
| 554 |
{ |
| 555 |
"data": "expiration_date", |
| 556 |
"name": "expiration_date", |
| 557 |
"type": "date", |
| 558 |
"title": _("Expiration date"), |
| 559 |
"orderable": true, |
| 560 |
"render": function( data, type, row, meta ) { |
| 561 |
return $date(data); |
| 562 |
} |
| 480 |
}, |
563 |
}, |
| 481 |
"embed": [ |
564 |
{ |
| 482 |
"biblio", |
565 |
"data": "biblio.title", |
| 483 |
"item", |
566 |
"name": "title", |
| 484 |
"pickup_library", |
567 |
"title": _("Title"), |
| 485 |
"patron" |
568 |
"orderable": true, |
| 486 |
], |
569 |
"render": function( data, type, row, meta ) { |
| 487 |
"destroy": true, |
570 |
return '<a href="/cgi-bin/koha/catalogue/detail.pl?' + |
| 488 |
"autoWidth": false, |
571 |
'biblionumber=' + encodeURIComponent( row.biblio_id ) + '">' + escape_str( data ) + '</a>'; |
| 489 |
"processing": true, |
572 |
} |
| 490 |
"columns": [ |
573 |
}, |
| 491 |
{ |
574 |
{ |
| 492 |
"data": "expiration_date", |
575 |
"data": "item.external_id", |
| 493 |
"name": "expiration_date", |
576 |
"name": "barcode", |
| 494 |
"type": "date", |
577 |
"title": _("Barcode"), |
| 495 |
"title": _("Expiration date"), |
578 |
"defaultContent": _(""), |
| 496 |
"orderable": true, |
579 |
"orderable": true, |
| 497 |
"render": function( data, type, row, meta ) { |
580 |
"render": function( data, type, row, meta ) { |
| 498 |
return $date(data); |
581 |
if( row.item ){ |
| 499 |
} |
582 |
let item_id = encodeURIComponent( row.item_id ); |
| 500 |
}, |
583 |
let biblio_id = encodeURIComponent( row.biblio_id ); |
| 501 |
{ |
584 |
return '<a href="/cgi-bin/koha/catalogue/moredetail.pl?' + |
| 502 |
"data": "biblio.title", |
585 |
'itemnumber='+ item_id +'&biblionumber='+ biblio_id +'&' + |
| 503 |
"name": "title", |
586 |
'bi='+ biblio_id +'#item'+ item_id +'">' + escape_str( data ) + '</a>' |
| 504 |
"title": _("Title"), |
|
|
| 505 |
"orderable": true, |
| 506 |
"render": function( data, type, row, meta ) { |
| 507 |
return '<a href="/cgi-bin/koha/catalogue/detail.pl?' + |
| 508 |
'biblionumber=' + encodeURIComponent( row.biblio_id ) + '">' + escape_str( data ) + '</a>'; |
| 509 |
} |
| 510 |
}, |
| 511 |
{ |
| 512 |
"data": "item.external_id", |
| 513 |
"name": "barcode", |
| 514 |
"title": _("Barcode"), |
| 515 |
"defaultContent": _(""), |
| 516 |
"orderable": true, |
| 517 |
"render": function( data, type, row, meta ) { |
| 518 |
if( row.item ){ |
| 519 |
let item_id = encodeURIComponent( row.item_id ); |
| 520 |
let biblio_id = encodeURIComponent( row.biblio_id ); |
| 521 |
return '<a href="/cgi-bin/koha/catalogue/moredetail.pl?' + |
| 522 |
'itemnumber='+ item_id +'&biblionumber='+ biblio_id +'&' + |
| 523 |
'bi='+ biblio_id +'#item'+ item_id +'">' + escape_str( data ) + '</a>' |
| 524 |
} |
| 525 |
} |
| 526 |
}, |
| 527 |
{ |
| 528 |
"data": "patron_id", |
| 529 |
"name": "patron", |
| 530 |
"title": _("Patron"), |
| 531 |
"orderable": true, |
| 532 |
"render": function( data, type, row, meta ) { |
| 533 |
let patron_to_html = $patron_to_html(row.patron, { url: true, display_cardnumber: true, hide_patron_name }); |
| 534 |
return patron_to_html; |
| 535 |
} |
| 536 |
}, |
| 537 |
{ |
| 538 |
"data": "status", |
| 539 |
"name": "status", |
| 540 |
"className": "found_status", |
| 541 |
"title": _("Status"), |
| 542 |
"orderable": true, |
| 543 |
"render": function( data, type, row, meta ) { |
| 544 |
let status = _("No status"); |
| 545 |
if ( data == "T" ) { |
| 546 |
status = _("In transit"); |
| 547 |
} else if( data == "P" ) { |
| 548 |
status = _("In processing"); |
| 549 |
} else if( data == "W" ) { |
| 550 |
status = _("Waiting"); |
| 551 |
} |
| 552 |
return status; |
| 553 |
} |
| 554 |
}, |
| 555 |
{ |
| 556 |
"data": "pickup_library_id", |
| 557 |
"name": "pickup_library", |
| 558 |
"title": _("Hold pickup library"), |
| 559 |
"orderable": true, |
| 560 |
"render": function( data, type, row, meta ) { |
| 561 |
return escape_str( row.pickup_library.name ); |
| 562 |
} |
| 563 |
}, |
| 564 |
{ |
| 565 |
"data": "suspended", |
| 566 |
"name": "suspended", |
| 567 |
"title": _("Suspended"), |
| 568 |
"orderable": true, |
| 569 |
"render": function( data, type, row, meta ) { |
| 570 |
return data == 0 ? _("No") : _("Yes"); |
| 571 |
} |
| 572 |
}, |
| 573 |
{ |
| 574 |
"data": "suspended_until", |
| 575 |
"name": "suspended_until", |
| 576 |
"title": _("Suspended until"), |
| 577 |
"orderable": true, |
| 578 |
"render": function( data, type, row, meta ) { |
| 579 |
return $date( data ); |
| 580 |
} |
587 |
} |
| 581 |
}, |
588 |
} |
| 582 |
{ |
589 |
}, |
| 583 |
"data": "notes", |
590 |
{ |
| 584 |
"name": "notes", |
591 |
"data": "patron_id", |
| 585 |
"title": _("Notes"), |
592 |
"name": "patron", |
| 586 |
"orderable": true, |
593 |
"title": _("Patron"), |
| 587 |
"render": function( data, type, row, meta ) { |
594 |
"orderable": true, |
| 588 |
return escape_str( data ); |
595 |
"render": function( data, type, row, meta ) { |
|
|
596 |
let patron_to_html = $patron_to_html(row.patron, { url: true, display_cardnumber: true, hide_patron_name }); |
| 597 |
return patron_to_html; |
| 598 |
} |
| 599 |
}, |
| 600 |
{ |
| 601 |
"data": "status", |
| 602 |
"name": "status", |
| 603 |
"className": "found_status", |
| 604 |
"title": _("Status"), |
| 605 |
"orderable": true, |
| 606 |
"render": function( data, type, row, meta ) { |
| 607 |
let status = _("No status"); |
| 608 |
if ( data == "T" ) { |
| 609 |
status = _("In transit"); |
| 610 |
} else if( data == "P" ) { |
| 611 |
status = _("In processing"); |
| 612 |
} else if( data == "W" ) { |
| 613 |
status = _("Waiting"); |
| 589 |
} |
614 |
} |
|
|
615 |
return status; |
| 590 |
} |
616 |
} |
| 591 |
] |
617 |
}, |
| 592 |
}, table_settings, 0, filters); |
618 |
{ |
|
|
619 |
"data": "pickup_library_id", |
| 620 |
"name": "pickup_library", |
| 621 |
"title": _("Hold pickup library"), |
| 622 |
"orderable": true, |
| 623 |
"render": function( data, type, row, meta ) { |
| 624 |
return escape_str( row.pickup_library.name ); |
| 625 |
} |
| 626 |
}, |
| 627 |
{ |
| 628 |
"data": "suspended", |
| 629 |
"name": "suspended", |
| 630 |
"title": _("Suspended"), |
| 631 |
"orderable": true, |
| 632 |
"render": function( data, type, row, meta ) { |
| 633 |
return data == 0 ? _("No") : _("Yes"); |
| 634 |
} |
| 635 |
}, |
| 636 |
{ |
| 637 |
"data": "suspended_until", |
| 638 |
"name": "suspended_until", |
| 639 |
"title": _("Suspended until"), |
| 640 |
"orderable": true, |
| 641 |
"render": function( data, type, row, meta ) { |
| 642 |
return $date( data ); |
| 643 |
} |
| 644 |
}, |
| 645 |
{ |
| 646 |
"data": "notes", |
| 647 |
"name": "notes", |
| 648 |
"title": _("Notes"), |
| 649 |
"orderable": true, |
| 650 |
"render": function( data, type, row, meta ) { |
| 651 |
return escape_str( data ); |
| 652 |
} |
| 653 |
} |
| 654 |
] |
| 655 |
}, table_settings, 0, filters); |
| 593 |
|
656 |
|
| 594 |
var modified_message = '<div class="alert alert-info">'+hold_ids.length+' hold(s) have been modified!</div>'; |
657 |
var modified_message = '<div class="alert alert-info">'+hold_ids.length+' hold(s) have been modified!</div>'; |
| 595 |
$("#modified_holds_results-wrapper").prepend(modified_message); |
658 |
$("#modified_holds_results-wrapper").prepend(modified_message); |
| 596 |
|
659 |
|
| 597 |
}); |
660 |
}); |
| 598 |
</script> |
661 |
</script> |