|
Lines 99-104
Link Here
|
| 99 |
[% IF CAN_user_borrowers_edit_borrowers %] |
99 |
[% IF CAN_user_borrowers_edit_borrowers %] |
| 100 |
<button id="merge-patrons" class="btn btn-sm btn-default disabled" disabled="disabled" type="submit"><i class="fa fa-compress" aria-hidden="true"></i> Merge selected patrons</button> |
100 |
<button id="merge-patrons" class="btn btn-sm btn-default disabled" disabled="disabled" type="submit"><i class="fa fa-compress" aria-hidden="true"></i> Merge selected patrons</button> |
| 101 |
[% END %] |
101 |
[% END %] |
|
|
102 |
<div id="patron_search_selected" class="btn-group" style="display:none;"> |
| 103 |
<span></span> |
| 104 |
<a href="#" id="clear-patron-selection"><i class="fa fa-remove"></i> Clear</a> |
| 105 |
</div> |
| 102 |
</div> |
106 |
</div> |
| 103 |
</div> |
107 |
</div> |
| 104 |
[% END %] |
108 |
[% END %] |
|
Lines 245-258
Link Here
|
| 245 |
getSearchByLocation( false ); |
249 |
getSearchByLocation( false ); |
| 246 |
}); |
250 |
}); |
| 247 |
|
251 |
|
|
|
252 |
function showPatronSelections( number ){ |
| 253 |
$("#patron_search_selected").show().find("span").text(_("Patrons selected: " + number ) ); |
| 254 |
} |
| 255 |
|
| 248 |
$(document).ready(function() { |
256 |
$(document).ready(function() { |
| 249 |
$('#merge-patrons').prop('disabled', true); |
257 |
$('#merge-patrons').prop('disabled', true); |
| 250 |
$('#memberresultst').on('change', 'input.selection', function() { |
258 |
$('#memberresultst').on('change', 'input.selection', function() { |
| 251 |
if ( $('.selection:checked').length > 1 ) { |
259 |
var patron_search_selections = JSON.parse( localStorage.getItem("patron_search_selections") ) || []; |
|
|
260 |
var borrowernumber = $(this).val(); |
| 261 |
if( $(this).prop("checked") ){ |
| 262 |
patron_search_selections.push( $(this).val() ); |
| 263 |
localStorage.setItem('patron_search_selections', JSON.stringify( patron_search_selections )); |
| 264 |
showPatronSelections( patron_search_selections.length ); |
| 265 |
} else { |
| 266 |
var filtered = patron_search_selections.filter(function( value ){ |
| 267 |
return value !== borrowernumber; |
| 268 |
}); |
| 269 |
if( filtered.length > 0 ){ |
| 270 |
localStorage.setItem('patron_search_selections', JSON.stringify( filtered )); |
| 271 |
patron_search_selections = filtered; |
| 272 |
showPatronSelections( filtered.length ); |
| 273 |
} else { |
| 274 |
patron_search_selections = []; |
| 275 |
localStorage.removeItem('patron_search_selections'); |
| 276 |
$("#patron_search_selected").hide(); |
| 277 |
} |
| 278 |
} |
| 279 |
if ( patron_search_selections.length > 1 ) { |
| 252 |
/* More than one checkbox has been checked */ |
280 |
/* More than one checkbox has been checked */ |
| 253 |
$('#merge-patrons').prop('disabled', false).removeClass("disabled"); |
281 |
$('#merge-patrons').prop('disabled', false).removeClass("disabled"); |
| 254 |
$("#patronlist-menu").removeClass("disabled").prop("disabled", false); |
282 |
$("#patronlist-menu").removeClass("disabled").prop("disabled", false); |
| 255 |
} else if ( $('.selection:checked').length == 1 ) { |
283 |
} else if ( patron_search_selections.length == 1 ) { |
| 256 |
/* At least one checkbox has been checked */ |
284 |
/* At least one checkbox has been checked */ |
| 257 |
$('#merge-patrons').prop('disabled', true).addClass("disabled"); |
285 |
$('#merge-patrons').prop('disabled', true).addClass("disabled"); |
| 258 |
$("#patronlist-menu").removeClass("disabled").prop("disabled", false); |
286 |
$("#patronlist-menu").removeClass("disabled").prop("disabled", false); |
|
Lines 264-280
Link Here
|
| 264 |
}); |
292 |
}); |
| 265 |
|
293 |
|
| 266 |
$('#merge-patrons').on('click', function() { |
294 |
$('#merge-patrons').on('click', function() { |
| 267 |
var merge_patrons_url = 'merge-patrons.pl?' + $('.selection:checked') |
295 |
var patron_search_selections = JSON.parse( localStorage.getItem("patron_search_selections") ) || []; |
| 268 |
.map(function() { |
296 |
var merge_patrons_url = 'merge-patrons.pl?id=' + patron_search_selections.join("&id="); |
| 269 |
return "id=" + $(this).val() |
|
|
| 270 |
}).get().join('&'); |
| 271 |
window.location.href = merge_patrons_url; |
297 |
window.location.href = merge_patrons_url; |
| 272 |
}); |
298 |
}); |
| 273 |
|
299 |
|
| 274 |
$("#patronlist-dropdown").on("click", ".patron-list-add", function(e){ |
300 |
$("#clear-patron-selection").on("click", function(e){ |
| 275 |
e.preventDefault(); |
301 |
e.preventDefault(); |
|
|
302 |
$(".selection").prop("checked", false).change(); |
| 303 |
localStorage.removeItem("patron_search_selections"); |
| 304 |
$("#patron_search_selected").hide(); |
| 305 |
}); |
| 276 |
|
306 |
|
| 277 |
if ( $("#memberresultst input:checkbox:checked").length == 0 ) { |
307 |
$("#patronlist-dropdown").on("click", ".patron-list-add", function(e){ |
|
|
308 |
e.preventDefault(); |
| 309 |
var patron_search_selections = JSON.parse( localStorage.getItem("patron_search_selections") ) || []; |
| 310 |
if ( patron_search_selections.length == 0 ) { |
| 278 |
alert( _("You have not selected any patrons to add to a list!") ); |
311 |
alert( _("You have not selected any patrons to add to a list!") ); |
| 279 |
$(".btn-group").removeClass("open"); /* Close button menu */ |
312 |
$(".btn-group").removeClass("open"); /* Close button menu */ |
| 280 |
return false; |
313 |
return false; |
|
Lines 496-501
Link Here
|
| 496 |
stickTo: "#searchresults", |
529 |
stickTo: "#searchresults", |
| 497 |
stickyClass: "floating" |
530 |
stickyClass: "floating" |
| 498 |
}); |
531 |
}); |
|
|
532 |
}, |
| 533 |
"drawCallback": function(){ |
| 534 |
prepSelections(); |
| 499 |
} |
535 |
} |
| 500 |
}, columns_settings); |
536 |
}, columns_settings); |
| 501 |
update_searched(); |
537 |
update_searched(); |
|
Lines 505-539
Link Here
|
| 505 |
}); |
541 |
}); |
| 506 |
|
542 |
|
| 507 |
function patronListAdd(){ |
543 |
function patronListAdd(){ |
| 508 |
var borrowernumbers = []; |
544 |
var borrowernumbers = JSON.parse( localStorage.getItem("patron_search_selections") ) || []; |
| 509 |
$("#memberresultst").find("input:checkbox:checked").each(function(){ |
545 |
if ( borrowernumbers.length > 0 ){ |
| 510 |
borrowernumbers.push($(this).val()); |
546 |
var data = { |
| 511 |
}); |
547 |
add_to_patron_list: $("#add_to_patron_list").val(), |
| 512 |
var data = { |
548 |
new_patron_list: $("#new_patron_list").val(), |
| 513 |
add_to_patron_list: $("#add_to_patron_list").val(), |
549 |
borrowernumbers: borrowernumbers |
| 514 |
new_patron_list: $("#new_patron_list").val(), |
550 |
}; |
| 515 |
borrowernumbers: borrowernumbers |
551 |
$.ajax({ |
| 516 |
}; |
552 |
data: data, |
| 517 |
$.ajax({ |
553 |
type: 'POST', |
| 518 |
data: data, |
554 |
url: '/cgi-bin/koha/svc/members/add_to_list', |
| 519 |
type: 'POST', |
555 |
success: function(data) { |
| 520 |
url: '/cgi-bin/koha/svc/members/add_to_list', |
556 |
$("#patron_list_dialog").show(); |
| 521 |
success: function(data) { |
557 |
$("#patron_list_dialog > span.patrons-length").html(data.patrons_added_to_list); |
| 522 |
$("#patron_list_dialog").show(); |
558 |
$("#patron_list_dialog > a").attr("href", "/cgi-bin/koha/patron_lists/list.pl?patron_list_id=" + data.patron_list.patron_list_id); |
| 523 |
$("#patron_list_dialog > span.patrons-length").html(data.patrons_added_to_list); |
559 |
$("#patron_list_dialog > a").html(data.patron_list.name); |
| 524 |
$("#patron_list_dialog > a").attr("href", "/cgi-bin/koha/patron_lists/list.pl?patron_list_id=" + data.patron_list.patron_list_id); |
560 |
|
| 525 |
$("#patron_list_dialog > a").html(data.patron_list.name); |
561 |
if ( $('#add_to_patron_list').val() == 'new' ) { |
| 526 |
|
562 |
/* Add a new entry to the menu */ |
| 527 |
if ( $('#add_to_patron_list').val() == 'new' ) { |
563 |
$("#patronlist-dropdown .divider").before('<li><a class="patron-list-add" href="#" data-listid="' + data.patron_list.patron_list_id + '">' + data.patron_list.name + '</li>'); |
| 528 |
/* Add a new entry to the menu */ |
564 |
} |
| 529 |
$("#patronlist-dropdown .divider").before('<li><a class="patron-list-add" href="#" data-listid="' + data.patron_list.patron_list_id + '">' + data.patron_list.name + '</li>'); |
565 |
}, |
|
|
566 |
error: function() { |
| 567 |
alert( _("An error occurred. Patron list could not be updated.") ); |
| 530 |
} |
568 |
} |
| 531 |
}, |
569 |
}); |
| 532 |
error: function() { |
570 |
return true; |
| 533 |
alert( _("An error occurred. Patron list could not be updated.") ); |
571 |
} else { |
|
|
572 |
alert( _("You have not selected any patrons to add to a list!") ); |
| 573 |
return false; |
| 574 |
} |
| 575 |
} |
| 576 |
|
| 577 |
function prepSelections(){ |
| 578 |
var selected_patrons = JSON.parse( localStorage.getItem("patron_search_selections") ); |
| 579 |
if( selected_patrons && selected_patrons.length > 0 ){ |
| 580 |
showPatronSelections( selected_patrons.length ); |
| 581 |
|
| 582 |
$('#merge-patrons').prop('disabled', true); |
| 583 |
$("input.selection").each(function(){ |
| 584 |
var cardnumber = $(this).val(); |
| 585 |
if( selected_patrons.indexOf( cardnumber ) >= 0 ){ |
| 586 |
$(this).prop("checked", true ); |
| 587 |
} |
| 588 |
}); |
| 589 |
|
| 590 |
if( selected_patrons.length > 1 ){ |
| 591 |
$('#merge-patrons').removeClass("disabled").prop('disabled', false); |
| 592 |
$('#patronlist-menu').removeClass("disabled").prop('disabled', false); |
| 534 |
} |
593 |
} |
| 535 |
}); |
594 |
} |
| 536 |
return true; |
|
|
| 537 |
} |
595 |
} |
| 538 |
|
596 |
|
| 539 |
function getSearchByLocation( setstate ){ |
597 |
function getSearchByLocation( setstate ){ |