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(){
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 $("#printclearscreen").click(function(){
75 printx_window("slip");
76 window.location.replace("/cgi-bin/koha/circ/circulation.pl");
78 $("#searchtohold").click(function(){
82 $("#select_patron_messages").on("change",function(){
83 $("#borrower_message").val( $(this).val() );
86 $(".edit-patronimage").on("click", function(e){
88 var borrowernumber = $(this).data("borrowernumber");
89 $.get("/cgi-bin/koha/members/moremember.pl", { borrowernumber : borrowernumber }, function( data ){
90 var image_form = $(data).find("#picture-upload");
91 image_form.show().find(".cancel").remove();
92 $("#patronImageEdit .modal-body").html( image_form );
94 var modalTitle = $(this).attr("title");
95 $("#patronImageEdit .modal-title").text(modalTitle);
96 $("#patronImageEdit").modal("show");
103 function searchfield_date_tooltip(filter) {
104 var field = "#searchmember" + filter;
105 var type = "#searchfieldstype" + filter;
106 if ( $(type).val() == 'dateofbirth' ) {
107 var MSG_DATE_FORMAT = "";
108 if( dateformat == 'us' ){
109 MSG_DATE_FORMAT = MSG_DATE_FORMAT_US;
110 } else if( dateformat == 'iso' ){
111 MSG_DATE_FORMAT = MSG_DATE_FORMAT_ISO;
112 } else if( dateformat == 'metric' ){
113 MSG_DATE_FORMAT = MSG_DATE_FORMAT_METRIC;
114 } else if( dateformat == 'dmydot' ){
115 MSG_DATE_FORMAT = MSG_DATE_FORMAT_DMYDOT;
117 $(field).attr("title", MSG_DATE_FORMAT).tooltip('show');
119 $(field).tooltip('destroy');
123 function confirm_updatechild() {
124 var is_confirmed = window.confirm( MSG_CONFIRM_UPDATE_CHILD );
126 window.location='/cgi-bin/koha/members/update-child.pl?op=update&borrowernumber=' + borrowernumber;
130 function update_child() {
131 if( number_of_adult_categories > 1 ){
132 window.open('/cgi-bin/koha/members/update-child.pl?op=multi&borrowernumber=' + borrowernumber,'UpdateChild','width=400,height=300,toolbar=no,scrollbars=yes,resizable=yes');
134 confirm_updatechild();
138 function confirm_reregistration() {
139 var is_confirmed = window.confirm( MSG_CONFIRM_RENEW_PATRON );
141 window.location = '/cgi-bin/koha/members/setstatus.pl?borrowernumber=' + borrowernumber + '&destination=' + destination + '&reregistration=y';
144 function export_barcodes() {
145 window.open('/cgi-bin/koha/members/readingrec.pl?borrowernumber=' + borrowernumber + '&op=export_barcodes');
147 var slip_re = /slip/;
148 function printx_window(print_type) {
149 var handler = print_type.match(slip_re) ? "printslip" : "summary-print";
150 window.open("/cgi-bin/koha/members/" + handler + ".pl?borrowernumber=" + borrowernumber + "&print=" + print_type, "printwindow");
153 function searchToHold(){
154 var date = new Date();
155 date.setTime(date.getTime() + (10 * 60 * 1000));
156 $.cookie("holdfor", borrowernumber, { path: "/", expires: date });
157 location.href="/cgi-bin/koha/catalogue/search.pl";