1 /* global borrowernumber advsearch dateformat _ CAN_user_borrowers_edit_borrowers NorwegianPatronDBEnable CATCODE_MULTI catcode destination */
3 $(document).ready(function(){
4 $("#filteraction_off, #filteraction_on").on('click', function(e) {
6 $('#filters').toggle();
7 $('.filteraction').toggle();
10 $("#filteraction_on").toggle();
13 $("#filteraction_off").toggle();
15 $("#searchfieldstype").change(function() {
16 var MSG_DATE_FORMAT = "";
17 if ( $(this).val() == 'dateofbirth' ) {
18 if( dateformat == 'us' ){
19 MSG_DATE_FORMAT = _("Dates of birth should be entered in the format 'MM/DD/YYYY'");
20 } else if( dateformat == 'iso' ){
21 MSG_DATE_FORMAT = _("Dates of birth should be entered in the format 'YYYY-MM-DD'");
22 } else if( dateformat == 'metric' ){
23 MSG_DATE_FORMAT = _("Dates of birth should be entered in the format 'DD/MM/YYYY'");
24 } else if( dateformat == 'dmydot' ){
25 MSG_DATE_FORMAT = _("Dates of birth should be entered in the format 'DD.MM.YYYY'");
27 $('#searchmember').attr("title", MSG_DATE_FORMAT).tooltip('show');
29 $('#searchmember').tooltip('destroy');
33 if( CAN_user_borrowers_edit_borrowers ){
34 if( NorwegianPatronDBEnable == 1 ){
35 $("#deletepatronlocal").click(function(){
36 confirm_local_deletion();
37 $(".btn-group").removeClass("open");
40 $("#deletepatronremote").click(function(){
41 confirm_remote_deletion();
42 $(".btn-group").removeClass("open");
45 $("#deletepatronboth").click(function(){
46 confirm_both_deletion();
47 $(".btn-group").removeClass("open");
51 $("#deletepatron").click(function(){
52 window.location='/cgi-bin/koha/members/deletemem.pl?member=' + borrowernumber;
55 $("#renewpatron").click(function(){
56 confirm_reregistration();
57 $(".btn-group").removeClass("open");
60 $("#updatechild").click(function(e){
61 if( $(this).data("toggle") == "tooltip"){ // Disabled menu option has tooltip attribute
65 $(".btn-group").removeClass("open");
70 $("#updatechild, #patronflags, #renewpatron, #deletepatron, #exportbarcodes").tooltip();
71 $("#exportcheckins").click(function(){
73 $(".btn-group").removeClass("open");
76 $("#printsummary").click(function(){
77 printx_window("page");
78 $(".btn-group").removeClass("open");
81 $("#printslip").click(function(){
82 printx_window("slip");
83 $(".btn-group").removeClass("open");
86 $("#printquickslip").click(function(){
87 printx_window("qslip");
88 $(".btn-group").removeClass("open");
91 $("#print_overdues").click(function(){
92 window.open("/cgi-bin/koha/members/print_overdues.pl?borrowernumber=" + borrowernumber, "printwindow");
93 $(".btn-group").removeClass("open");
96 $("#searchtohold").click(function(){
100 $("#select_patron_messages").on("change",function(){
101 $("#borrower_message").val( $(this).val() );
104 function confirm_local_deletion() {
105 var is_confirmed = window.confirm(_("Are you sure you want to delete this patron from the local database? This cannot be undone."));
107 window.location='/cgi-bin/koha/members/deletemem.pl?member=' + borrowernumber + '&deletelocal=true&deleteremote=false';
110 function confirm_remote_deletion() {
111 var is_confirmed = window.confirm(_("Are you sure you want to delete this patron from the Norwegian national patron database? This cannot be undone."));
113 window.location='/cgi-bin/koha/members/deletemem.pl?member=' + borrowernumber + '&deletelocal=false&deleteremote=true';
116 function confirm_both_deletion() {
117 var is_confirmed = window.confirm(_("Are you sure you want to delete this patron both from the local database and from the Norwegian national patron database? This cannot be undone."));
119 window.location='/cgi-bin/koha/members/deletemem.pl?member=' + borrowernumber + '&deletelocal=true&deleteremote=true';
123 function confirm_updatechild() {
124 var is_confirmed = window.confirm(_("Are you sure you want to update this child to an Adult category? This cannot be undone."));
126 window.location='/cgi-bin/koha/members/update-child.pl?op=update&borrowernumber=' + borrowernumber + '&catcode=' + catcode + '&catcode_multi=' + CATCODE_MULTI;
130 function update_child() {
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(_("Are you sure you want to renew this patron's registration?"));
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";