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-253
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() { |
|
|
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 |
showPatronSelections( filtered.length ); |
272 |
} else { |
273 |
localStorage.removeItem('patron_search_selections'); |
274 |
$("#patron_search_selected").hide(); |
275 |
} |
276 |
} |
251 |
if ( $('.selection:checked').length > 1 ) { |
277 |
if ( $('.selection:checked').length > 1 ) { |
252 |
/* More than one checkbox has been checked */ |
278 |
/* More than one checkbox has been checked */ |
253 |
$('#merge-patrons').prop('disabled', false).removeClass("disabled"); |
279 |
$('#merge-patrons').prop('disabled', false).removeClass("disabled"); |
Lines 264-280
Link Here
|
264 |
}); |
290 |
}); |
265 |
|
291 |
|
266 |
$('#merge-patrons').on('click', function() { |
292 |
$('#merge-patrons').on('click', function() { |
267 |
var merge_patrons_url = 'merge-patrons.pl?' + $('.selection:checked') |
293 |
var patron_search_selections = JSON.parse( localStorage.getItem("patron_search_selections") ) || []; |
268 |
.map(function() { |
294 |
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; |
295 |
window.location.href = merge_patrons_url; |
272 |
}); |
296 |
}); |
273 |
|
297 |
|
274 |
$("#patronlist-dropdown").on("click", ".patron-list-add", function(e){ |
298 |
$("#clear-patron-selection").on("click", function(e){ |
275 |
e.preventDefault(); |
299 |
e.preventDefault(); |
|
|
300 |
$(".selection").prop("checked", false).change(); |
301 |
localStorage.removeItem("patron_search_selections"); |
302 |
$("#patron_search_selected").hide(); |
303 |
}); |
276 |
|
304 |
|
277 |
if ( $("#memberresultst input:checkbox:checked").length == 0 ) { |
305 |
$("#patronlist-dropdown").on("click", ".patron-list-add", function(e){ |
|
|
306 |
e.preventDefault(); |
307 |
var patron_search_selections = JSON.parse( localStorage.getItem("patron_search_selections") ) || []; |
308 |
if ( patron_search_selections.length == 0 ) { |
278 |
alert( _("You have not selected any patrons to add to a list!") ); |
309 |
alert( _("You have not selected any patrons to add to a list!") ); |
279 |
$(".btn-group").removeClass("open"); /* Close button menu */ |
310 |
$(".btn-group").removeClass("open"); /* Close button menu */ |
280 |
return false; |
311 |
return false; |
Lines 496-501
Link Here
|
496 |
stickTo: "#searchresults", |
527 |
stickTo: "#searchresults", |
497 |
stickyClass: "floating" |
528 |
stickyClass: "floating" |
498 |
}); |
529 |
}); |
|
|
530 |
}, |
531 |
"drawCallback": function(){ |
532 |
prepSelections(); |
499 |
} |
533 |
} |
500 |
}, columns_settings); |
534 |
}, columns_settings); |
501 |
update_searched(); |
535 |
update_searched(); |
Lines 505-539
Link Here
|
505 |
}); |
539 |
}); |
506 |
|
540 |
|
507 |
function patronListAdd(){ |
541 |
function patronListAdd(){ |
508 |
var borrowernumbers = []; |
542 |
var borrowernumbers = JSON.parse( localStorage.getItem("patron_search_selections") ) || []; |
509 |
$("#memberresultst").find("input:checkbox:checked").each(function(){ |
543 |
if ( borrowernumbers.length > 0 ){ |
510 |
borrowernumbers.push($(this).val()); |
544 |
var data = { |
511 |
}); |
545 |
add_to_patron_list: $("#add_to_patron_list").val(), |
512 |
var data = { |
546 |
new_patron_list: $("#new_patron_list").val(), |
513 |
add_to_patron_list: $("#add_to_patron_list").val(), |
547 |
borrowernumbers: borrowernumbers |
514 |
new_patron_list: $("#new_patron_list").val(), |
548 |
}; |
515 |
borrowernumbers: borrowernumbers |
549 |
$.ajax({ |
516 |
}; |
550 |
data: data, |
517 |
$.ajax({ |
551 |
type: 'POST', |
518 |
data: data, |
552 |
url: '/cgi-bin/koha/svc/members/add_to_list', |
519 |
type: 'POST', |
553 |
success: function(data) { |
520 |
url: '/cgi-bin/koha/svc/members/add_to_list', |
554 |
$("#patron_list_dialog").show(); |
521 |
success: function(data) { |
555 |
$("#patron_list_dialog > span.patrons-length").html(data.patrons_added_to_list); |
522 |
$("#patron_list_dialog").show(); |
556 |
$("#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); |
557 |
$("#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); |
558 |
|
525 |
$("#patron_list_dialog > a").html(data.patron_list.name); |
559 |
if ( $('#add_to_patron_list').val() == 'new' ) { |
526 |
|
560 |
/* Add a new entry to the menu */ |
527 |
if ( $('#add_to_patron_list').val() == 'new' ) { |
561 |
$("#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 */ |
562 |
} |
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>'); |
563 |
}, |
|
|
564 |
error: function() { |
565 |
alert( _("An error occurred. Patron list could not be updated.") ); |
530 |
} |
566 |
} |
531 |
}, |
567 |
}); |
532 |
error: function() { |
568 |
return true; |
533 |
alert( _("An error occurred. Patron list could not be updated.") ); |
569 |
} else { |
|
|
570 |
alert( _("You have not selected any patrons to add to a list!") ); |
571 |
return false; |
572 |
} |
573 |
} |
574 |
|
575 |
function prepSelections(){ |
576 |
var selected_patrons = JSON.parse( localStorage.getItem("patron_search_selections") ); |
577 |
if( selected_patrons && selected_patrons.length > 0 ){ |
578 |
showPatronSelections( selected_patrons.length ); |
579 |
|
580 |
$('#merge-patrons').prop('disabled', true); |
581 |
$("input.selection").each(function(){ |
582 |
var cardnumber = $(this).val(); |
583 |
if( selected_patrons.indexOf( cardnumber ) >= 0 ){ |
584 |
$(this).prop("checked", true ); |
585 |
} |
586 |
}); |
587 |
|
588 |
if( selected_patrons.length > 1 ){ |
589 |
$('#merge-patrons').removeClass("disabled").prop('disabled', false); |
590 |
$('#patronlist-menu').removeClass("disabled").prop('disabled', false); |
534 |
} |
591 |
} |
535 |
}); |
592 |
} |
536 |
return true; |
|
|
537 |
} |
593 |
} |
538 |
|
594 |
|
539 |
function getSearchByLocation( setstate ){ |
595 |
function getSearchByLocation( setstate ){ |