1 /* global borrowernumber advsearch dateformat _ CAN_user_borrowers_edit_borrowers number_of_adult_categories destination */
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();
18 $("#searchfieldstype").change(function() {
19 var MSG_DATE_FORMAT = "";
20 if ( $(this).val() == 'dateofbirth' ) {
21 if( dateformat == 'us' ){
22 MSG_DATE_FORMAT = _("Dates of birth should be entered in the format 'MM/DD/YYYY'");
23 } else if( dateformat == 'iso' ){
24 MSG_DATE_FORMAT = _("Dates of birth should be entered in the format 'YYYY-MM-DD'");
25 } else if( dateformat == 'metric' ){
26 MSG_DATE_FORMAT = _("Dates of birth should be entered in the format 'DD/MM/YYYY'");
27 } else if( dateformat == 'dmydot' ){
28 MSG_DATE_FORMAT = _("Dates of birth should be entered in the format 'DD.MM.YYYY'");
30 $('#searchmember').attr("title", MSG_DATE_FORMAT).tooltip('show');
32 $('#searchmember').tooltip('destroy');
36 if( CAN_user_borrowers_edit_borrowers ){
37 $("#deletepatron").click(function(){
38 window.location='/cgi-bin/koha/members/deletemem.pl?member=' + borrowernumber;
40 $("#renewpatron").click(function(){
41 confirm_reregistration();
42 $(".btn-group").removeClass("open");
45 $("#updatechild").click(function(e){
46 if( $(this).data("toggle") == "tooltip"){ // Disabled menu option has tooltip attribute
50 $(".btn-group").removeClass("open");
55 $("#updatechild, #patronflags, #renewpatron, #deletepatron, #exportbarcodes").tooltip();
56 $("#exportcheckins").click(function(){
58 $(".btn-group").removeClass("open");
61 $("#printsummary").click(function(){
62 printx_window("page");
63 $(".btn-group").removeClass("open");
66 $("#printslip").click(function(){
67 printx_window("slip");
68 $(".btn-group").removeClass("open");
71 $("#printquickslip").click(function(){
72 printx_window("qslip");
73 $(".btn-group").removeClass("open");
76 $("#print_overdues").click(function(){
77 window.open("/cgi-bin/koha/members/print_overdues.pl?borrowernumber=" + borrowernumber, "printwindow");
78 $(".btn-group").removeClass("open");
81 $("#printclearscreen").click(function(){
82 printx_window("slip");
83 window.location.replace("/cgi-bin/koha/circ/circulation.pl");
85 $("#searchtohold").click(function(){
89 $("#select_patron_messages").on("change",function(){
90 $("#borrower_message").val( $(this).val() );
93 $(".edit-patronimage").on("click", function(e){
95 var borrowernumber = $(this).data("borrowernumber");
96 $.get("/cgi-bin/koha/members/moremember.pl", { borrowernumber : borrowernumber }, function( data ){
97 var image_form = $(data).find("#picture-upload");
98 image_form.show().find(".cancel").remove();
99 $("#patronImageEdit .modal-body").html( image_form );
101 var modalTitle = $(this).attr("title");
102 $("#patronImageEdit .modal-title").text(modalTitle);
103 $("#patronImageEdit").modal("show");
107 function confirm_updatechild() {
108 var is_confirmed = window.confirm(_("Are you sure you want to update this child to an Adult category? This cannot be undone."));
110 window.location='/cgi-bin/koha/members/update-child.pl?op=update&borrowernumber=' + borrowernumber;
114 function update_child() {
115 if( number_of_adult_categories > 1 ){
116 window.open('/cgi-bin/koha/members/update-child.pl?op=multi&borrowernumber=' + borrowernumber,'UpdateChild','width=400,height=300,toolbar=no,scrollbars=yes,resizable=yes');
118 confirm_updatechild();
122 function confirm_reregistration() {
123 var is_confirmed = window.confirm(_("Are you sure you want to renew this patron's registration?"));
125 window.location = '/cgi-bin/koha/members/setstatus.pl?borrowernumber=' + borrowernumber + '&destination=' + destination + '&reregistration=y';
128 function export_barcodes() {
129 window.open('/cgi-bin/koha/members/readingrec.pl?borrowernumber=' + borrowernumber + '&op=export_barcodes');
131 var slip_re = /slip/;
132 function printx_window(print_type) {
133 var handler = print_type.match(slip_re) ? "printslip" : "summary-print";
134 window.open("/cgi-bin/koha/members/" + handler + ".pl?borrowernumber=" + borrowernumber + "&print=" + print_type, "printwindow");
137 function searchToHold(){
138 var date = new Date();
139 date.setTime(date.getTime() + (10 * 60 * 1000));
140 $.cookie("holdfor", borrowernumber, { path: "/", expires: date });
141 location.href="/cgi-bin/koha/catalogue/search.pl";