|
Lines 498-500
$(document).ready(function() {
Link Here
|
| 498 |
}); |
498 |
}); |
| 499 |
|
499 |
|
| 500 |
}); |
500 |
}); |
|
|
501 |
|
| 502 |
async function load_patron_holds_table(biblio_id, split_data) { |
| 503 |
const { name: split_name, value: split_value } = split_data; |
| 504 |
const table_id = `#patron_holds_table_${biblio_id}_${split_value}`; |
| 505 |
hold_table_settings.table = `patron_holds_table_${biblio_id}_${split_data.value}`; |
| 506 |
let url = `/api/v1/holds/?q={"me.biblio_id":${biblio_id}`; |
| 507 |
|
| 508 |
if (split_name === 'branch' && split_value !== 'any') { |
| 509 |
url += `, "me.pickup_library_id":"${split_value}"`; |
| 510 |
} else if (split_name === 'itemtype' && split_value !== 'any') { |
| 511 |
url += `, "me.itemtype":"${split_value}"`; |
| 512 |
} else if (split_name === 'branch_itemtype') { |
| 513 |
const [branch, itemtype] = split_value.split('_'); |
| 514 |
url += itemtype === 'any' |
| 515 |
? `, "me.pickup_library_id":"${branch}"` |
| 516 |
: `, "me.pickup_library_id":"${branch}", "me.itemtype":"${itemtype}"`; |
| 517 |
} |
| 518 |
|
| 519 |
url += '}'; |
| 520 |
const totalHolds = $(table_id).data('total-holds'); |
| 521 |
const totalHoldsSelect = parseInt(totalHolds)+1; |
| 522 |
let pageStart; |
| 523 |
var holdsQueueTable = $(table_id).kohaTable({ |
| 524 |
ajax: { |
| 525 |
url: url, |
| 526 |
data: function (params) { |
| 527 |
pageStart = params.start; |
| 528 |
var query = { |
| 529 |
"_per_page": params.length, |
| 530 |
"_page": params.start / params.length + 1, |
| 531 |
"_order_by": "priority", |
| 532 |
"_match": "exact" |
| 533 |
}; |
| 534 |
return query; |
| 535 |
}, |
| 536 |
}, |
| 537 |
embed: ['patron', 'item', 'item_group'], |
| 538 |
columnDefs: [ |
| 539 |
{ |
| 540 |
targets: [2, 3], |
| 541 |
className: 'dt-body-nowrap' |
| 542 |
}, |
| 543 |
{ |
| 544 |
targets: [3, 9], |
| 545 |
visible: CAN_user_reserveforothers_modify_holds_priority ? true : false |
| 546 |
}, |
| 547 |
|
| 548 |
], |
| 549 |
columns: [ |
| 550 |
{ |
| 551 |
data: "hold_id", |
| 552 |
orderable: false, |
| 553 |
searchable: false, |
| 554 |
render: function( data, type, row, meta ) { |
| 555 |
return '<input type="checkbox" class="select_hold" data-id="'+data+'"/>'; |
| 556 |
} |
| 557 |
}, |
| 558 |
{ |
| 559 |
data: "priority", |
| 560 |
orderable: false, |
| 561 |
searchable: false, |
| 562 |
render: function(data, type, row, meta) { |
| 563 |
let select = '<select name="rank-request" class="rank-request" data-id="'+row.hold_id; |
| 564 |
if(CAN_user_reserveforothers_modify_holds_priority && split_name == 'any') { |
| 565 |
for ( var i=0; i < totalHoldsSelect; i++ ){ |
| 566 |
let selected; |
| 567 |
let value; |
| 568 |
let desc; |
| 569 |
if (data == i && row.status == 'T') { |
| 570 |
select += '" disabled="disabled">'; |
| 571 |
selected = " selected='selected' "; |
| 572 |
value = 'T'; |
| 573 |
desc = 'In transit'; |
| 574 |
} else if (data == i && row.status == 'P') { |
| 575 |
select += '" disabled="disabled">'; |
| 576 |
selected = " selected='selected' "; |
| 577 |
value = 'P'; |
| 578 |
desc = 'In processing'; |
| 579 |
} else if (data == i && row.status == 'W'){ |
| 580 |
select += '" disabled="disabled">'; |
| 581 |
selected = " selected='selected' "; |
| 582 |
value = 'W'; |
| 583 |
desc = 'Waiting'; |
| 584 |
} else if (data == i && !row.status) { |
| 585 |
select += '">'; |
| 586 |
selected = " selected='selected' "; |
| 587 |
value = data; |
| 588 |
desc = data; |
| 589 |
} else { |
| 590 |
if (i != 0) { |
| 591 |
select += '">'; |
| 592 |
value = i; |
| 593 |
desc = i; |
| 594 |
} else { |
| 595 |
select += '">'; |
| 596 |
} |
| 597 |
} |
| 598 |
if (value) { |
| 599 |
select += '<option value="'+ value +'"'+selected+'>'+desc+'</option>'; |
| 600 |
} |
| 601 |
} |
| 602 |
}else { |
| 603 |
if (row.status == 'T') { |
| 604 |
select += '" disabled="disabled"><option value="T" selected="selected">In transit</option></select>'; |
| 605 |
} else if (row.status == 'P') { |
| 606 |
select += '" disabled="disabled"><option value="P" selected="selected">In processing</option></select>'; |
| 607 |
} else if (row.status == 'W') { |
| 608 |
select += '" disabled="disabled"><option value="W" selected="selected">Waiting</option></select>'; |
| 609 |
} else { |
| 610 |
if (HoldsSplitQueue !== "nothing" && HoldsSplitQueueNumbering === 'virtual') { |
| 611 |
let virtualPriority = pageStart + meta.row + 1; |
| 612 |
select += '" disabled="disabled"><option value="'+ data +'" selected="selected">'+ virtualPriority +'</option></select>'; |
| 613 |
} else { |
| 614 |
select += '" disabled="disabled"><option value="'+ data +'" selected="selected">'+ data +'</option></select>'; |
| 615 |
} |
| 616 |
} |
| 617 |
} |
| 618 |
select += '</select>'; |
| 619 |
return select; |
| 620 |
} |
| 621 |
}, |
| 622 |
{ |
| 623 |
data: "", |
| 624 |
orderable: false, |
| 625 |
searchable: false, |
| 626 |
render: function(data, type, row, meta) { |
| 627 |
if (row.status) { |
| 628 |
return null; |
| 629 |
} |
| 630 |
let buttons = '<a class="hold-arrow move-hold" title="Move hold up" href="#" data-move-hold="up" data-priority="'+row.priority+'" reserve_id="'+row.hold_id+'"><i class="fa fa-lg icon-move-hold-up" aria-hidden="true"></i></a>'; |
| 631 |
buttons += '<a class="hold-arrow move-hold" title="Move hold to top" href="#" data-move-hold="top" data-priority="'+row.priority+'" reserve_id="'+row.hold_id+'"><i class="fa fa-lg icon-move-hold-top" aria-hidden="true"></i></a>'; |
| 632 |
buttons += '<a class="hold-arrow move-hold" title="Move hold to bottom" href="#" data-move-hold="bottom" data-priority="'+row.priority+'" reserve_id="'+row.hold_id+'"><i class="fa fa-lg icon-move-hold-bottom" aria-hidden="true"></i></a>'; |
| 633 |
buttons += '<a class="hold-arrow move-hold" title="Move hold down" href="#" data-move-hold="down" data-priority="'+row.priority+'" reserve_id="'+row.hold_id+'"><i class="fa fa-lg icon-move-hold-down" aria-hidden="true"></i></a>'; |
| 634 |
return buttons; |
| 635 |
} |
| 636 |
}, |
| 637 |
{ |
| 638 |
data: "patron.cardnumber", |
| 639 |
orderable: false, |
| 640 |
searchable: true, |
| 641 |
render: function(data, type, row, meta) { |
| 642 |
if(data == null) { |
| 643 |
let library = libraries.find(library => library._id == row.pickup_library_id); |
| 644 |
return __("A patron from library %s").format(library.name); |
| 645 |
} else { |
| 646 |
return '<a href="/cgi-bin/koha/members/moremember.pl?borrowernumber='+row.patron.patron_id+'">'+data+'</a>'; |
| 647 |
} |
| 648 |
} |
| 649 |
}, |
| 650 |
{ |
| 651 |
data: "notes", |
| 652 |
orderable: false, |
| 653 |
searchable: false, |
| 654 |
render: function(data, type, row, meta) { |
| 655 |
return data; |
| 656 |
} |
| 657 |
}, |
| 658 |
{ |
| 659 |
data: "hold_date", |
| 660 |
orderable: false, |
| 661 |
searchable: false, |
| 662 |
render: function(data, type, row, meta) { |
| 663 |
if (AllowHoldDateInFuture) { |
| 664 |
return '<input type="text" class="holddate" value="'+$date(data, {dateformat:"rfc3339"})+'" size="10" name="hold_date" data-id="'+row.hold_id+'" data-current-date="'+data+'"/>'; |
| 665 |
} else { |
| 666 |
return $date(data); |
| 667 |
} |
| 668 |
} |
| 669 |
}, |
| 670 |
{ |
| 671 |
data: "expiration_date", |
| 672 |
orderable: false, |
| 673 |
searchable: false, |
| 674 |
render: function(data, type, row, meta) { |
| 675 |
return '<input type="text" class="expirationdate" value="'+$date(data, {dateformat:"rfc3339"})+'" size="10" name="expiration_date" data-id="'+row.hold_id+'" data-current-date="'+data+'"/>'; |
| 676 |
} |
| 677 |
}, |
| 678 |
{ |
| 679 |
data: "pickup_library_id", |
| 680 |
orderable: false, |
| 681 |
searchable: false, |
| 682 |
render: function(data, type, row, meta) { |
| 683 |
var branchSelect='<select priority='+row.priority+' class="hold_location_select" data-id="'+row.hold_id+'" reserve_id="'+row.hold_id+'" name="pick-location" data-pickup-location-source="hold">'; |
| 684 |
var libraryname; |
| 685 |
for ( var i=0; i < libraries.length; i++ ){ |
| 686 |
var selectedbranch; |
| 687 |
var setbranch; |
| 688 |
if( libraries[i]._id == data ){ |
| 689 |
selectedbranch = " selected='selected' "; |
| 690 |
setbranch = __(" (current) "); |
| 691 |
libraryname = libraries[i]._str; |
| 692 |
} else if ( libraries[i].pickup_location == false ) { |
| 693 |
continue; |
| 694 |
} else{ |
| 695 |
selectedbranch = ''; |
| 696 |
setbranch = ''; |
| 697 |
} |
| 698 |
branchSelect += '<option value="'+ libraries[i]._id.escapeHtml() +'"'+selectedbranch+'>'+libraries[i]._str.escapeHtml()+setbranch+'</option>'; |
| 699 |
} |
| 700 |
branchSelect +='</select>'; |
| 701 |
if ( row.status == 'T' ) { |
| 702 |
return __("Item being transferred to <strong>%s</strong>").format(libraryname); |
| 703 |
} else if (row.status == 'P') { |
| 704 |
return __("Item being processed at <strong>%s</strong>").format(libraryname); |
| 705 |
} |
| 706 |
else if (row.status == 'W') { |
| 707 |
return __("Item waiting at <strong>%s</strong> since %s").format(libraryname, $date(row.waiting_date)); |
| 708 |
} else { |
| 709 |
return branchSelect; |
| 710 |
} |
| 711 |
} |
| 712 |
}, |
| 713 |
{ |
| 714 |
data: "", |
| 715 |
orderable: false, |
| 716 |
searchable: false, |
| 717 |
render: function(data, type, row, meta) { |
| 718 |
if (row.item_id) { |
| 719 |
return '<a href="/cgi-bin/koha/catalogue/moredetail.pl?biblionumber='+row.biblio_id+'&itemnumber='+row.item_id+'">'+row.item.external_id+'</a>' |
| 720 |
} else if (row.item_group_id) { |
| 721 |
return __("Next available item from group <strong>%s</strong>").format( row.item_group.description ); |
| 722 |
} else { |
| 723 |
if (row.non_priority) { |
| 724 |
return '<em>'+__("Next available")+'</em><br/><i>'+__("Non priority hold")+'</i>'; |
| 725 |
} else { |
| 726 |
return '<em>'+__("Next available")+'</em>'; |
| 727 |
} |
| 728 |
} |
| 729 |
} |
| 730 |
}, |
| 731 |
{ |
| 732 |
data: "", |
| 733 |
orderable: false, |
| 734 |
searchable: false, |
| 735 |
render: function(data, type, row, meta) { |
| 736 |
if (row.item_id) { |
| 737 |
return null |
| 738 |
} else { |
| 739 |
if(row.lowest_priority){ |
| 740 |
return '<a class="hold-arrow toggle-lowest-priority" title="Remove lowest priority" href="#" data-op="cud-setLowestPriority" data-borrowernumber="'+ row.patron_id +'" data-biblionumber="'+ biblio_id +'" data-reserve_id="'+ row.hold_id +'" data-date="'+ row.hold_date +'"><i class="fa fa-lg fa-rotate-90 icon-unset-lowest" aria-hidden="true"></i></a>'; |
| 741 |
} else { |
| 742 |
return '<a class="hold-arrow toggle-lowest-priority" title="Set lowest priority" href="#" data-op="cud-setLowestPriority" data-borrowernumber="'+ row.patron_id +'" data-biblionumber="'+ biblio_id +'" data-reserve_id="'+ row.hold_id +'" data-date="'+ row.hold_date +'"><i class="fa fa-lg fa-rotate-90 icon-set-lowest" aria-hidden="true"></i></a>'; |
| 743 |
} |
| 744 |
} |
| 745 |
} |
| 746 |
}, |
| 747 |
{ |
| 748 |
data: "hold_id", |
| 749 |
orderable: false, |
| 750 |
searchable: false, |
| 751 |
render: function(data, type, row, meta) { |
| 752 |
return '<a class="cancel-hold" title="Cancel hold" reserve_id="'+data+'" href="#"><i class="fa fa-trash" aria-label="Cancel hold"></i></a>'; |
| 753 |
} |
| 754 |
}, |
| 755 |
{ |
| 756 |
data: "hold_id", |
| 757 |
orderable: false, |
| 758 |
searchable: false, |
| 759 |
render: function(data, type, row, meta) { |
| 760 |
if (row.status) { |
| 761 |
var link_value = row.status == 'T' ? __("Revert transit status") : __("Revert waiting status"); |
| 762 |
return '<a class="btn btn-default submit-form-link" href="#" id="revert_hold_'+data+'" data-op="cud-move" data-where="down" data-first_priority="1" data-last_priority="'+ totalHolds +'" data-prev_priority="0" data-next_priority="1" data-borrowernumber="'+ row.patron_id +'" data-biblionumber="'+ biblio_id +'" data-itemnumber="'+ row.item_id +'" data-reserve_id="'+ row.hold_id +'" data-date="'+ row.hold_date +'" data-action="request.pl" data-method="post">'+ link_value +'</a>'; |
| 763 |
} else { |
| 764 |
let td = ''; |
| 765 |
if (SuspendHoldsIntranet) { |
| 766 |
td += '<button class="btn btn-default btn-xs toggle-suspend" data-id="'+data+'" data-biblionumber="'+biblio_id+'" data-suspended="'+row.suspended+'">' |
| 767 |
if ( row.suspended ) { |
| 768 |
td += '<i class="fa fa-play" aria-hidden="true"></i> '+__("Resume")+'</button>'; |
| 769 |
} else { |
| 770 |
td += '<i class="fa fa-pause" aria-hidden="true"></i> '+__("Suspend")+'</button>'; |
| 771 |
} |
| 772 |
if (AutoResumeSuspendedHolds) { |
| 773 |
if (row.suspended) { |
| 774 |
td += '<label for="suspend_until_'+data+'">'+__("Suspend on")+' </label>'; |
| 775 |
} else { |
| 776 |
td += '<label for="suspend_until_'+data+'">'+__("Suspend until")+' </label>'; |
| 777 |
} |
| 778 |
td += '<input type="text" name="suspend_until_'+data+'" data-id="'+data+'" size="10" value="'+$date(row.suspended_until, {dateformat:"rfc3339"})+'" class="suspenddate" data-flatpickr-futuredate="true" data-suspend-date="'+row.suspended_until+'" />'; |
| 779 |
} |
| 780 |
return td; |
| 781 |
} else { |
| 782 |
return null; |
| 783 |
} |
| 784 |
} |
| 785 |
} |
| 786 |
}, |
| 787 |
{ |
| 788 |
data: "hold_id", |
| 789 |
orderable: false, |
| 790 |
searchable: false, |
| 791 |
render: function(data, type, row, meta) { |
| 792 |
if (row.status == 'W' || row.status == 'T') { |
| 793 |
return '<a class="btn btn-default btn-xs printholdslip" data-reserve_id="'+data+'">'+__("Print slip")+'</a>'; |
| 794 |
} else { |
| 795 |
return ''; |
| 796 |
} |
| 797 |
} |
| 798 |
}, |
| 799 |
] |
| 800 |
},hold_table_settings); |
| 801 |
$(table_id).on( 'draw.dt', function () { |
| 802 |
// Remove the search box. Don't know why it isn't working in the table settings |
| 803 |
$(this).parent().find(".pager .table_controls .dt-search").remove(); |
| 804 |
$(this).parent().find(".pager .table_controls .dt-buttons .dt_button_clear_filter").remove(); |
| 805 |
var MSG_CANCEL_SELECTED = _("Cancel selected (%s)"); |
| 806 |
$('.cancel_selected_holds').html(MSG_CANCEL_SELECTED.format($('.holds_table .select_hold:checked').length)); |
| 807 |
$('.holds_table .select_hold').each(function() { |
| 808 |
if(localStorage.selectedHolds && localStorage.selectedHolds.includes($(this).data('id'))) { |
| 809 |
$(this).prop('checked', true); |
| 810 |
} |
| 811 |
}); |
| 812 |
$('.holds_table .select_hold_all').on("click",function() { |
| 813 |
var table = $(this).parents('.holds_table'); |
| 814 |
var count = $('.select_hold:checked', table).length; |
| 815 |
$('.select_hold', table).prop('checked', !count); |
| 816 |
$(this).prop('checked', !count); |
| 817 |
$(this).parent().parent().toggleClass('selected'); |
| 818 |
$('.cancel_selected_holds').html(MSG_CANCEL_SELECTED.format($('.holds_table .select_hold:checked').length)); |
| 819 |
localStorage.selectedHolds = $('.holds_table .select_hold:checked').toArray().map(el => $(el).data('id')); |
| 820 |
|
| 821 |
}); |
| 822 |
$('.holds_table .select_hold').on("click", function() { |
| 823 |
var table = $(this).parents('.holds_table'); |
| 824 |
var count = $('.select_hold:not(:checked)', table).length; |
| 825 |
$('.select_hold_all', table).prop('checked', !count); |
| 826 |
$(this).parent().parent().toggleClass('selected'); |
| 827 |
$('.cancel_selected_holds').html(MSG_CANCEL_SELECTED.format($('.holds_table .select_hold:checked').length)); |
| 828 |
localStorage.selectedHolds = $('.holds_table .select_hold:checked').toArray().map(el => $(el).data('id')); |
| 829 |
}); |
| 830 |
$(".cancel-hold").on("click",function(e) { |
| 831 |
e.preventDefault; |
| 832 |
var res_id = $(this).attr('reserve_id'); |
| 833 |
$('.select_hold').prop('checked', false); |
| 834 |
$('.select_hold_all').prop('checked', false); |
| 835 |
$('.cancel_selected_holds').html(MSG_CANCEL_SELECTED.format(0)); |
| 836 |
$('#cancelModal').modal('show').find('#cancelModalConfirmBtn').attr("data-id", res_id); |
| 837 |
delete localStorage.selectedHolds; |
| 838 |
}); |
| 839 |
$('.cancel_selected_holds').on("click", function(e) { |
| 840 |
e.preventDefault(); |
| 841 |
if($('.holds_table .select_hold:checked').length) { |
| 842 |
delete localStorage.selectedHolds; |
| 843 |
$('#cancelModal').modal('show'); |
| 844 |
} |
| 845 |
return false; |
| 846 |
}); |
| 847 |
// Remove any previously attached handlers |
| 848 |
$("#cancelModalConfirmBtn").off("click"); |
| 849 |
// Attach the handler to the button |
| 850 |
$("#cancelModalConfirmBtn").one("click",function(e) { |
| 851 |
e.preventDefault(); |
| 852 |
let hold_ids; |
| 853 |
const hold_id = $('#cancelModal').modal('show').find('#cancelModalConfirmBtn').attr("data-id"); |
| 854 |
let reason = $("#modal-cancellation-reason").val(); |
| 855 |
if (hold_id) { |
| 856 |
hold_ids = [hold_id]; |
| 857 |
} else { |
| 858 |
hold_ids = $('.holds_table .select_hold:checked').toArray().map(el => $(el).data('id')); |
| 859 |
} |
| 860 |
$('#cancelModal').find('.modal-footer #cancelModalConfirmBtn').before('<img src="/intranet-tmpl/prog/img/spinner-small.gif" alt="" style="padding-right: 10px;"/>'); |
| 861 |
deleteHolds(hold_ids, reason); |
| 862 |
$('#cancelModal').modal('show').find('#cancelModalConfirmBtn').attr("data-id", ""); |
| 863 |
|
| 864 |
}); |
| 865 |
async function deleteHolds (hold_ids, reason) { |
| 866 |
for (const hold_id of hold_ids) { |
| 867 |
await deleteHold(hold_id, reason); |
| 868 |
$('#cancelModal').find('.modal-body').append('<p class="hold-cancelled">'+__("Hold")+' '+hold_id+' '+__("cancelled")+'</p>'); |
| 869 |
await new Promise(resolve => setTimeout(resolve, 1000)); |
| 870 |
} |
| 871 |
|
| 872 |
holdsQueueTable.api().ajax.reload(null, false); |
| 873 |
setTimeout(() => { |
| 874 |
$('#cancelModal').modal('hide'); |
| 875 |
$('#cancelModal').find('.modal-footer #cancelModalConfirmBtn').prev('img').remove(); |
| 876 |
$('#cancelModal').find('.modal-body').find('.hold-cancelled').remove(); |
| 877 |
}); |
| 878 |
} |
| 879 |
async function deleteHold(hold_id, reason) { |
| 880 |
try { |
| 881 |
await $.ajax({ |
| 882 |
method: "DELETE", |
| 883 |
url: '/api/v1/holds/' + encodeURIComponent(hold_id), |
| 884 |
data: JSON.stringify(reason), |
| 885 |
}); |
| 886 |
} catch (error) { |
| 887 |
console.error("Error when deleting hold: " + hold_id); |
| 888 |
} |
| 889 |
} |
| 890 |
$(".holddate, .expirationdate").flatpickr({ |
| 891 |
onReady: function(selectedDates, dateStr, instance) { |
| 892 |
$(instance.altInput) |
| 893 |
.wrap("<span class='flatpickr_wrapper'></span>") |
| 894 |
.after($("<a/>") |
| 895 |
.attr("href", "#") |
| 896 |
.addClass("clear_date") |
| 897 |
.addClass("fa fa-times") |
| 898 |
.addClass("ps-2") |
| 899 |
.on("click", function(e) { |
| 900 |
e.preventDefault(); |
| 901 |
instance.clear(); |
| 902 |
}) |
| 903 |
.attr("aria-hidden", true) |
| 904 |
); |
| 905 |
}, |
| 906 |
onChange: function (selectedDates, dateStr, instance){ |
| 907 |
let hold_id = $(instance.input).attr('data-id'); |
| 908 |
let fieldname = $(instance.input).attr('name'); |
| 909 |
let current_date = $(instance.input).attr('data-current-date'); |
| 910 |
dateStr = dateStr ? dateStr : null; |
| 911 |
let req = fieldname == "hold_date" ? { "hold_date": dateStr } : { "expiration_date": dateStr }; |
| 912 |
if (current_date != dateStr) { |
| 913 |
$.ajax({ |
| 914 |
method: "PATCH", |
| 915 |
url: '/api/v1/holds/' + encodeURIComponent(hold_id), |
| 916 |
contentType: 'application/json', |
| 917 |
data: JSON.stringify(req), |
| 918 |
success: function( data ){ holdsQueueTable.api().ajax.reload(null, false); }, |
| 919 |
error: function( jqXHR, textStatus, errorThrown) { |
| 920 |
holdsQueueTable.api().ajax.reload(null, false); |
| 921 |
}, |
| 922 |
}); |
| 923 |
} |
| 924 |
} |
| 925 |
}); |
| 926 |
$(".suspenddate").flatpickr({ |
| 927 |
onReady: function(selectedDates, dateStr, instance) { |
| 928 |
$(instance.altInput) |
| 929 |
.wrap("<span class='flatpickr_wrapper'></span>") |
| 930 |
.after($("<a/>") |
| 931 |
.attr("href", "#") |
| 932 |
.addClass("clear_date") |
| 933 |
.addClass("fa fa-times") |
| 934 |
.addClass("ps-2") |
| 935 |
.on("click", function(e) { |
| 936 |
e.preventDefault(); |
| 937 |
instance.clear(); |
| 938 |
}) |
| 939 |
.attr("aria-hidden", true) |
| 940 |
); |
| 941 |
}, |
| 942 |
}); |
| 943 |
$(".toggle-suspend").one("click",function(e) { |
| 944 |
e.preventDefault(); |
| 945 |
const hold_id = $(this).data('id'); |
| 946 |
const suspended = $(this).attr('data-suspended'); |
| 947 |
const input = $(`.suspenddate[data-id="${hold_id}"]`); |
| 948 |
const method = suspended == 'true' ? 'DELETE' : 'POST'; |
| 949 |
let end_date = input.val() && method == 'POST' ? input.val() : null; |
| 950 |
let params = (end_date !== null && end_date !== '') ? JSON.stringify({ "end_date": end_date }) : null; |
| 951 |
$.ajax({ |
| 952 |
method: method, |
| 953 |
url: '/api/v1/holds/' + encodeURIComponent(hold_id) +'/suspension', |
| 954 |
contentType: 'application/json', |
| 955 |
data: params, |
| 956 |
success: function( data ){ |
| 957 |
holdsQueueTable.api().ajax.reload(null, false); |
| 958 |
}, |
| 959 |
error: function( jqXHR, textStatus, errorThrown) { |
| 960 |
holdsQueueTable.api().ajax.reload(null, false); |
| 961 |
alert('There was an error:'+textStatus+" "+errorThrown); |
| 962 |
}, |
| 963 |
}); |
| 964 |
}); |
| 965 |
$(".rank-request").on("change", function(e){ |
| 966 |
e.preventDefault(); |
| 967 |
const hold_id = $(this).data('id'); |
| 968 |
let priority = e.target.value; |
| 969 |
$.ajax({ |
| 970 |
method: "PUT", |
| 971 |
url: '/api/v1/holds/' + encodeURIComponent(hold_id) +'/priority', |
| 972 |
data: JSON.stringify(priority), |
| 973 |
success: function( data ){ holdsQueueTable.api().ajax.reload(null, false); }, |
| 974 |
error: function( jqXHR, textStatus, errorThrown) { |
| 975 |
alert('There was an error:'+textStatus+" "+errorThrown); |
| 976 |
}, |
| 977 |
}); |
| 978 |
}); |
| 979 |
$(".move-hold").one("click", function(e){ |
| 980 |
e.preventDefault(); |
| 981 |
let toPosition = $(this).attr('data-move-hold'); |
| 982 |
let priority = $(this).attr('data-priority'); |
| 983 |
var res_id = $(this).attr('reserve_id'); |
| 984 |
var moveTo; |
| 985 |
if (toPosition == 'up'){ |
| 986 |
moveTo = parseInt(priority)-1; |
| 987 |
} |
| 988 |
if (toPosition == 'down'){ |
| 989 |
moveTo = parseInt(priority)+1; |
| 990 |
} |
| 991 |
if (toPosition == 'top'){ |
| 992 |
moveTo = 1; |
| 993 |
} |
| 994 |
if (toPosition == 'bottom'){ |
| 995 |
moveTo = totalHolds; |
| 996 |
} |
| 997 |
$.ajax({ |
| 998 |
method: "PUT", |
| 999 |
url: '/api/v1/holds/' + encodeURIComponent(res_id) +'/priority', |
| 1000 |
data: JSON.stringify(moveTo), |
| 1001 |
success: function( data ){ |
| 1002 |
holdsQueueTable.api().ajax.reload(null, false); |
| 1003 |
}, |
| 1004 |
error: function( jqXHR, textStatus, errorThrown) { |
| 1005 |
alert('There was an error:'+textStatus+" "+errorThrown); |
| 1006 |
}, |
| 1007 |
}); |
| 1008 |
}); |
| 1009 |
$(".toggle-lowest-priority").one("click", function(e){ |
| 1010 |
e.preventDefault(); |
| 1011 |
var res_id = $(this).attr('data-reserve_id'); |
| 1012 |
$.ajax({ |
| 1013 |
method: "PUT", |
| 1014 |
url: '/api/v1/holds/' + encodeURIComponent(res_id) +'/lowest_priority', |
| 1015 |
success: function( data ){ holdsQueueTable.api().ajax.reload(null, false); }, |
| 1016 |
error: function( jqXHR, textStatus, errorThrown) { |
| 1017 |
alert('There was an error:'+textStatus+" "+errorThrown); |
| 1018 |
}, |
| 1019 |
}); |
| 1020 |
}); |
| 1021 |
$(".hold_location_select").on("change", function(){ |
| 1022 |
$(this).prop("disabled",true); |
| 1023 |
var cur_select = $(this); |
| 1024 |
var res_id = $(this).attr('reserve_id'); |
| 1025 |
$(this).after('<div id="updating_reserveno'+res_id+'" class="waiting"><img src="/intranet-tmpl/prog/img/spinner-small.gif" alt="" /><span class="waiting_msg"></span></div>'); |
| 1026 |
let api_url = '/api/v1/holds/' + encodeURIComponent(res_id) + '/pickup_location'; |
| 1027 |
$.ajax({ |
| 1028 |
method: "PUT", |
| 1029 |
url: api_url, |
| 1030 |
data: JSON.stringify({ "pickup_library_id": $(this).val() }), |
| 1031 |
headers: { "x-koha-override": "any" }, |
| 1032 |
success: function( data ){ holdsQueueTable.api().ajax.reload(null, false); }, |
| 1033 |
error: function( jqXHR, textStatus, errorThrown) { |
| 1034 |
alert('There was an error:'+textStatus+" "+errorThrown); |
| 1035 |
cur_select.prop("disabled",false); |
| 1036 |
$("#updating_reserveno"+res_id).remove(); |
| 1037 |
cur_select.val( cur_select.children('option[selected="selected"]').val() ); |
| 1038 |
}, |
| 1039 |
}); |
| 1040 |
}); |
| 1041 |
$('.printholdslip').one('click', function(){ |
| 1042 |
var reserve_id = $(this).attr('data-reserve_id'); |
| 1043 |
window.open("/cgi-bin/koha/circ/hold-transfer-slip.pl?reserve_id=" + reserve_id); |
| 1044 |
return false; |
| 1045 |
}); |
| 1046 |
}); |
| 1047 |
} |