1 /* global borrowernumber advsearch dateformat __ CAN_user_borrowers_edit_borrowers number_of_adult_categories destination Sticky */
3 $(document).ready(function(){
5 $("#filteraction_off, #filteraction_on").on('click', function(e) {
7 $('#filters').toggle();
8 $('.filteraction').toggle();
9 if (typeof Sticky !== "undefined" && typeof hcSticky === "function") {
10 Sticky.hcSticky('update');
14 $("#filteraction_on").toggle();
17 $("#filteraction_off").toggle();
20 searchfield_date_tooltip("");
21 searchfield_date_tooltip('_filter');
22 $("#searchfieldstype").change(function() {
23 searchfield_date_tooltip("");
25 $("#searchfieldstype_filter").change(function() {
26 searchfield_date_tooltip('_filter');
29 if( CAN_user_borrowers_edit_borrowers ){
30 $("#deletepatron").click(function(){
31 window.location='/cgi-bin/koha/members/deletemem.pl?member=' + borrowernumber;
33 $("#renewpatron").click(function(){
34 confirm_reregistration();
35 $(".btn-group").removeClass("open");
38 $("#updatechild").click(function(e){
39 if( $(this).data("toggle") == "tooltip"){ // Disabled menu option has tooltip attribute
43 $(".btn-group").removeClass("open");
48 $("#updatechild, #patronflags, #renewpatron, #deletepatron, #exportbarcodes").tooltip();
49 $("#exportcheckins").click(function(){
51 $(".btn-group").removeClass("open");
54 $("#printsummary").click(function(){
55 printx_window("page");
56 $(".btn-group").removeClass("open");
59 $("#printslip").click(function(){
60 printx_window("slip");
61 $(".btn-group").removeClass("open");
64 $("#printquickslip").click(function(){
65 printx_window("qslip");
66 $(".btn-group").removeClass("open");
69 $("#print_overdues").click(function(){
70 window.open("/cgi-bin/koha/members/print_overdues.pl?borrowernumber=" + borrowernumber, "printwindow");
71 $(".btn-group").removeClass("open");
74 $("#printcheckinslip").click(function(){
75 printx_window("checkinslip");
76 $(".btn-group").removeClass("open");
79 $("#printclearscreen").click(function(){
80 printx_window("slip");
81 window.location.replace("/cgi-bin/koha/circ/circulation.pl");
83 $("#searchtohold").click(function(){
87 $("#select_patron_messages").on("change",function(){
88 $("#borrower_message").val( $(this).val() );
91 $(".edit-patronimage").on("click", function(e){
93 var borrowernumber = $(this).data("borrowernumber");
94 $.get("/cgi-bin/koha/members/moremember.pl", { borrowernumber : borrowernumber }, function( data ){
95 var image_form = $(data).find("#picture-upload");
96 image_form.show().find(".cancel").remove();
97 $("#patronImageEdit .modal-body").html( image_form );
99 var modalTitle = $(this).attr("title");
100 $("#patronImageEdit .modal-title").text(modalTitle);
101 $("#patronImageEdit").modal("show");
108 function searchfield_date_tooltip(filter) {
109 var field = "#searchmember" + filter;
110 var type = "#searchfieldstype" + filter;
111 if ( $(type).val() == 'dateofbirth' ) {
112 var MSG_DATE_FORMAT = "";
113 if( dateformat == 'us' ){
114 MSG_DATE_FORMAT = __("Dates of birth should be entered in the format 'MM/DD/YYYY'");
115 } else if( dateformat == 'iso' ){
116 MSG_DATE_FORMAT = __("Dates of birth should be entered in the format 'YYYY-MM-DD'");
117 } else if( dateformat == 'metric' ){
118 MSG_DATE_FORMAT = __("Dates of birth should be entered in the format 'DD/MM/YYYY'");
119 } else if( dateformat == 'dmydot' ){
120 MSG_DATE_FORMAT = __("Dates of birth should be entered in the format 'DD.MM.YYYY'");
122 $(field).attr("title", MSG_DATE_FORMAT).tooltip('show');
124 $(field).tooltip('destroy');
128 function confirm_updatechild() {
129 var is_confirmed = window.confirm( __("Are you sure you want to update this child to an Adult category? This cannot be undone.") );
131 window.location='/cgi-bin/koha/members/update-child.pl?op=update&borrowernumber=' + borrowernumber;
135 function update_child() {
136 if( number_of_adult_categories > 1 ){
137 window.open('/cgi-bin/koha/members/update-child.pl?op=multi&borrowernumber=' + borrowernumber,'UpdateChild','width=400,height=300,toolbar=no,scrollbars=yes,resizable=yes');
139 confirm_updatechild();
143 function confirm_reregistration() {
144 var is_confirmed = window.confirm( __("Are you sure you want to renew this patron's registration?") );
146 window.location = '/cgi-bin/koha/members/setstatus.pl?borrowernumber=' + borrowernumber + '&destination=' + destination + '&reregistration=y';
149 function export_barcodes() {
150 window.open('/cgi-bin/koha/members/readingrec.pl?borrowernumber=' + borrowernumber + '&op=export_barcodes');
152 var slip_re = /slip/;
153 function printx_window(print_type) {
154 var handler = print_type.match(slip_re) ? "printslip" : "summary-print";
155 window.open("/cgi-bin/koha/members/" + handler + ".pl?borrowernumber=" + borrowernumber + "&print=" + print_type, "printwindow");
158 function searchToHold(){
159 var date = new Date();
160 date.setTime(date.getTime() + (10 * 60 * 1000));
161 $.cookie("holdfor", borrowernumber, { path: "/", expires: date });
162 location.href="/cgi-bin/koha/catalogue/search.pl";