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(){
62 $(".btn-group").removeClass("open");
66 $("#updatechild, #patronflags, #renewpatron, #deletepatron, #exportbarcodes").tooltip();
67 $("#exportcheckins").click(function(){
69 $(".btn-group").removeClass("open");
72 $("#printsummary").click(function(){
73 printx_window("page");
74 $(".btn-group").removeClass("open");
77 $("#printslip").click(function(){
78 printx_window("slip");
79 $(".btn-group").removeClass("open");
82 $("#printquickslip").click(function(){
83 printx_window("qslip");
84 $(".btn-group").removeClass("open");
87 $("#print_overdues").click(function(){
88 window.open("/cgi-bin/koha/members/print_overdues.pl?borrowernumber=" + borrowernumber, "printwindow");
89 $(".btn-group").removeClass("open");
92 $("#searchtohold").click(function(){
96 $("#select_patron_messages").on("change",function(){
97 $("#borrower_message").val( $(this).val() );
100 function confirm_local_deletion() {
101 var is_confirmed = window.confirm(_("Are you sure you want to delete this patron from the local database? This cannot be undone."));
103 window.location='/cgi-bin/koha/members/deletemem.pl?member=' + borrowernumber + '&deletelocal=true&deleteremote=false';
106 function confirm_remote_deletion() {
107 var is_confirmed = window.confirm(_("Are you sure you want to delete this patron from the Norwegian national patron database? This cannot be undone."));
109 window.location='/cgi-bin/koha/members/deletemem.pl?member=' + borrowernumber + '&deletelocal=false&deleteremote=true';
112 function confirm_both_deletion() {
113 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."));
115 window.location='/cgi-bin/koha/members/deletemem.pl?member=' + borrowernumber + '&deletelocal=true&deleteremote=true';
119 function confirm_updatechild() {
120 var is_confirmed = window.confirm(_("Are you sure you want to update this child to an Adult category? This cannot be undone."));
122 window.location='/cgi-bin/koha/members/update-child.pl?op=update&borrowernumber=' + borrowernumber + '&catcode=' + catcode + '&catcode_multi=' + CATCODE_MULTI;
126 function update_child() {
128 window.open('/cgi-bin/koha/members/update-child.pl?op=multi&borrowernumber=' + borrowernumber,'UpdateChild','width=400,height=300,toolbar=no,scrollbars=yes,resizable=yes');
130 confirm_updatechild();
134 function confirm_reregistration() {
135 var is_confirmed = window.confirm(_("Are you sure you want to renew this patron's registration?"));
137 window.location = '/cgi-bin/koha/members/setstatus.pl?borrowernumber=' + borrowernumber + '&destination=' + destination + '&reregistration=y';
140 function export_barcodes() {
141 window.open('/cgi-bin/koha/members/readingrec.pl?borrowernumber=' + borrowernumber + '&op=export_barcodes');
143 var slip_re = /slip/;
144 function printx_window(print_type) {
145 var handler = print_type.match(slip_re) ? "printslip" : "summary-print";
146 window.open("/cgi-bin/koha/members/" + handler + ".pl?borrowernumber=" + borrowernumber + "&print=" + print_type, "printwindow");
149 function searchToHold(){
150 var date = new Date();
151 date.setTime(date.getTime() + (10 * 60 * 1000));
152 $.cookie("holdfor", borrowernumber, { path: "/", expires: date });
153 location.href="/cgi-bin/koha/catalogue/search.pl";