1 /* global borrowernumber advsearch dateformat _ CAN_user_borrowers_edit_borrowers number_of_adult_categories destination Sticky MSG_DATE_FORMAT_US MSG_DATE_FORMAT_ISO MSG_DATE_FORMAT_METRIC MSG_DATE_FORMAT_DMYDOT MSG_CONFIRM_UPDATE_CHILD MSG_CONFIRM_RENEW_PATRON */
3 $(document).ready(function(){
4 $("#filteraction_off, #filteraction_on").on('click', function(e) {
6 $('#filters').toggle();
7 $('.filteraction').toggle();
8 if (typeof Sticky !== "undefined" && typeof hcSticky === "function") {
9 Sticky.hcSticky('update');
13 $("#filteraction_on").toggle();
16 $("#filteraction_off").toggle();
19 searchfield_date_tooltip();
20 $("#searchfieldstype").change(function() {
21 searchfield_date_tooltip();
24 if( CAN_user_borrowers_edit_borrowers ){
25 $("#deletepatron").click(function(){
26 window.location='/cgi-bin/koha/members/deletemem.pl?member=' + borrowernumber;
28 $("#renewpatron").click(function(){
29 confirm_reregistration();
30 $(".btn-group").removeClass("open");
33 $("#updatechild").click(function(e){
34 if( $(this).data("toggle") == "tooltip"){ // Disabled menu option has tooltip attribute
38 $(".btn-group").removeClass("open");
43 $("#updatechild, #patronflags, #renewpatron, #deletepatron, #exportbarcodes").tooltip();
44 $("#exportcheckins").click(function(){
46 $(".btn-group").removeClass("open");
49 $("#printsummary").click(function(){
50 printx_window("page");
51 $(".btn-group").removeClass("open");
54 $("#printslip").click(function(){
55 printx_window("slip");
56 $(".btn-group").removeClass("open");
59 $("#printquickslip").click(function(){
60 printx_window("qslip");
61 $(".btn-group").removeClass("open");
64 $("#print_overdues").click(function(){
65 window.open("/cgi-bin/koha/members/print_overdues.pl?borrowernumber=" + borrowernumber, "printwindow");
66 $(".btn-group").removeClass("open");
69 $("#printclearscreen").click(function(){
70 printx_window("slip");
71 window.location.replace("/cgi-bin/koha/circ/circulation.pl");
73 $("#searchtohold").click(function(){
77 $("#select_patron_messages").on("change",function(){
78 $("#borrower_message").val( $(this).val() );
81 $(".edit-patronimage").on("click", function(e){
83 var borrowernumber = $(this).data("borrowernumber");
84 $.get("/cgi-bin/koha/members/moremember.pl", { borrowernumber : borrowernumber }, function( data ){
85 var image_form = $(data).find("#picture-upload");
86 image_form.show().find(".cancel").remove();
87 $("#patronImageEdit .modal-body").html( image_form );
89 var modalTitle = $(this).attr("title");
90 $("#patronImageEdit .modal-title").text(modalTitle);
91 $("#patronImageEdit").modal("show");
95 function searchfield_date_tooltip() {
96 var MSG_DATE_FORMAT = "";
97 if ( $("#searchfieldstype").val() == 'dateofbirth' ) {
98 if( dateformat == 'us' ){
99 MSG_DATE_FORMAT = MSG_DATE_FORMAT_US;
100 } else if( dateformat == 'iso' ){
101 MSG_DATE_FORMAT = MSG_DATE_FORMAT_ISO;
102 } else if( dateformat == 'metric' ){
103 MSG_DATE_FORMAT = MSG_DATE_FORMAT_METRIC;
104 } else if( dateformat == 'dmydot' ){
105 MSG_DATE_FORMAT = MSG_DATE_FORMAT_DMYDOT;
107 $('#searchmember').attr("title", MSG_DATE_FORMAT).tooltip('show');
109 $('#searchmember').tooltip('destroy');
113 function confirm_updatechild() {
114 var is_confirmed = window.confirm( MSG_CONFIRM_UPDATE_CHILD );
116 window.location='/cgi-bin/koha/members/update-child.pl?op=update&borrowernumber=' + borrowernumber;
120 function update_child() {
121 if( number_of_adult_categories > 1 ){
122 window.open('/cgi-bin/koha/members/update-child.pl?op=multi&borrowernumber=' + borrowernumber,'UpdateChild','width=400,height=300,toolbar=no,scrollbars=yes,resizable=yes');
124 confirm_updatechild();
128 function confirm_reregistration() {
129 var is_confirmed = window.confirm( MSG_CONFIRM_RENEW_PATRON );
131 window.location = '/cgi-bin/koha/members/setstatus.pl?borrowernumber=' + borrowernumber + '&destination=' + destination + '&reregistration=y';
134 function export_barcodes() {
135 window.open('/cgi-bin/koha/members/readingrec.pl?borrowernumber=' + borrowernumber + '&op=export_barcodes');
137 var slip_re = /slip/;
138 function printx_window(print_type) {
139 var handler = print_type.match(slip_re) ? "printslip" : "summary-print";
140 window.open("/cgi-bin/koha/members/" + handler + ".pl?borrowernumber=" + borrowernumber + "&print=" + print_type, "printwindow");
143 function searchToHold(){
144 var date = new Date();
145 date.setTime(date.getTime() + (10 * 60 * 1000));
146 $.cookie("holdfor", borrowernumber, { path: "/", expires: date });
147 location.href="/cgi-bin/koha/catalogue/search.pl";