1 /* global borrowernumber advsearch dateformat __ CAN_user_borrowers_delete_borrowers CAN_user_borrowers_edit_borrowers number_of_adult_categories destination Sticky Cookies*/
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_delete_borrowers ){
30 $("#deletepatron").click(function(){
31 window.location='/cgi-bin/koha/members/deletemem.pl?member=' + borrowernumber;
34 if( CAN_user_borrowers_edit_borrowers ){
35 $("#renewpatron").click(function(){
36 confirm_reregistration();
37 $(".btn-group").removeClass("open");
40 $("#updatechild").click(function(e){
41 if( $(this).data("toggle") == "tooltip"){ // Disabled menu option has tooltip attribute
45 $(".btn-group").removeClass("open");
50 $(".delete_message").click(function(){
51 return window.confirm( __("Are you sure you want to delete this message? This cannot be undone.") );
54 $("#updatechild, #patronflags, #renewpatron, #deletepatron, #exportbarcodes").tooltip();
55 $("#exportcheckins").click(function(){
57 $(".btn-group").removeClass("open");
60 $("#printsummary").click(function(){
61 printx_window("page");
62 $(".btn-group").removeClass("open");
65 $("#printslip").click(function(){
66 printx_window("slip");
67 $(".btn-group").removeClass("open");
70 $("#printquickslip").click(function(){
71 printx_window("qslip");
72 $(".btn-group").removeClass("open");
75 $("#print_overdues").click(function(){
76 window.open("/cgi-bin/koha/members/print_overdues.pl?borrowernumber=" + borrowernumber, "printwindow");
77 $(".btn-group").removeClass("open");
80 $("#printcheckinslip").click(function(){
81 printx_window("checkinslip");
82 $(".btn-group").removeClass("open");
85 $("#printclearscreen").click(function(){
86 printx_window("slip");
87 window.location.replace("/cgi-bin/koha/circ/circulation.pl");
89 $("#printclearscreenq").click(function(){
90 printx_window("qslip");
91 window.location.replace("/cgi-bin/koha/circ/circulation.pl");
93 $("#searchtohold").click(function(){
97 $("#select_patron_messages").on("change",function(){
98 $("#borrower_message").val( $(this).val() );
101 $("#patronImageEdit").on("shown.bs.modal", function(){
105 $(".edit-patronimage").on("click", function(e){
107 var borrowernumber = $(this).data("borrowernumber");
108 var cardnumber = $(this).data("cardnumber");
109 var modalTitle = $(this).attr("title");
110 $("#patronImageEdit .modal-title").text(modalTitle);
111 $("#patronImageEdit").modal("show");
112 $("#patronImageEdit").on("hidden.bs.modal", function(){
113 /* Stop using the user's camera when modal is closed */
114 let viewfinder = document.getElementById("viewfinder");
115 if( viewfinder.srcObject ){
116 viewfinder.srcObject.getTracks().forEach( track => {
117 if( track.readyState == 'live' && track.kind === 'video'){
126 function searchfield_date_tooltip(filter) {
127 var field = "#searchmember" + filter;
128 var type = "#searchfieldstype" + filter;
129 if ( $(type).val() == 'dateofbirth' ) {
130 var MSG_DATE_FORMAT = "";
131 if( dateformat == 'us' ){
132 MSG_DATE_FORMAT = __("Dates of birth should be entered in the format 'MM/DD/YYYY'");
133 } else if( dateformat == 'iso' ){
134 MSG_DATE_FORMAT = __("Dates of birth should be entered in the format 'YYYY-MM-DD'");
135 } else if( dateformat == 'metric' ){
136 MSG_DATE_FORMAT = __("Dates of birth should be entered in the format 'DD/MM/YYYY'");
137 } else if( dateformat == 'dmydot' ){
138 MSG_DATE_FORMAT = __("Dates of birth should be entered in the format 'DD.MM.YYYY'");
140 $(field).attr("title", MSG_DATE_FORMAT).tooltip('show');
142 $(field).tooltip('destroy');
146 function confirm_updatechild() {
147 var is_confirmed = window.confirm( __("Are you sure you want to update this child to an Adult category? This cannot be undone.") );
149 window.location='/cgi-bin/koha/members/update-child.pl?op=update&borrowernumber=' + borrowernumber;
153 function update_child() {
154 if( number_of_adult_categories > 1 ){
155 window.open('/cgi-bin/koha/members/update-child.pl?op=multi&borrowernumber=' + borrowernumber,'UpdateChild','width=400,height=300,toolbar=no,scrollbars=yes,resizable=yes');
157 confirm_updatechild();
161 function confirm_reregistration() {
162 var is_confirmed = window.confirm( __("Are you sure you want to renew this patron's registration?") );
164 window.location = '/cgi-bin/koha/members/setstatus.pl?borrowernumber=' + borrowernumber + '&destination=' + destination + '&reregistration=y';
167 function export_barcodes() {
168 window.open('/cgi-bin/koha/members/readingrec.pl?borrowernumber=' + borrowernumber + '&op=export_barcodes');
170 var slip_re = /slip/;
171 function printx_window(print_type) {
172 var handler = print_type.match(slip_re) ? "printslip" : "summary-print";
173 window.open("/cgi-bin/koha/members/" + handler + ".pl?borrowernumber=" + borrowernumber + "&print=" + print_type, "printwindow");
176 function searchToHold(){
177 var date = new Date();
178 date.setTime(date.getTime() + (10 * 60 * 1000));
179 Cookies.set("holdfor", borrowernumber, { path: "/", expires: date, sameSite: 'Lax' });
180 location.href="/cgi-bin/koha/catalogue/search.pl";