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(){
4 searchfield_date_tooltip("");
5 searchfield_date_tooltip('_filter');
6 $("#searchfieldstype").change(function() {
7 searchfield_date_tooltip("");
9 $("#searchfieldstype_filter").change(function() {
10 searchfield_date_tooltip('_filter');
13 if( CAN_user_borrowers_delete_borrowers ){
14 $("#deletepatron").click(function(){
15 window.location='/cgi-bin/koha/members/deletemem.pl?member=' + borrowernumber;
18 if( CAN_user_borrowers_edit_borrowers ){
19 $("#renewpatron").click(function(){
20 confirm_reregistration();
21 $(".btn-group").removeClass("open");
24 $("#updatechild").click(function(e){
25 if( $(this).data("toggle") == "tooltip"){ // Disabled menu option has tooltip attribute
29 $(".btn-group").removeClass("open");
34 $(".delete_message").click(function(){
35 return window.confirm( __("Are you sure you want to delete this message? This cannot be undone.") );
38 $("#updatechild, #patronflags, #renewpatron, #deletepatron, #exportbarcodes").tooltip();
39 $("#exportcheckins").click(function(){
41 $(".btn-group").removeClass("open");
44 $("#printsummary").click(function(){
45 printx_window("page");
46 $(".btn-group").removeClass("open");
49 $("#printslip").click(function(){
50 printx_window("slip");
51 $(".btn-group").removeClass("open");
54 $("#printquickslip").click(function(){
55 printx_window("qslip");
56 $(".btn-group").removeClass("open");
59 $("#print_overdues").click(function(){
60 window.open("/cgi-bin/koha/members/print_overdues.pl?borrowernumber=" + borrowernumber, "printwindow");
61 $(".btn-group").removeClass("open");
64 $("#printcheckinslip").click(function(){
65 printx_window("checkinslip");
66 $(".btn-group").removeClass("open");
69 $("#printclearscreen").click(function(){
70 printx_window("slip");
71 window.location.replace("/cgi-bin/koha/circ/circulation.pl");
73 $("#printclearscreenq").click(function(){
74 printx_window("qslip");
75 window.location.replace("/cgi-bin/koha/circ/circulation.pl");
77 $("#searchtohold").click(function(){
81 $("#select_patron_messages").on("change",function(){
82 $("#borrower_message").val( $(this).val() );
85 $("#patronImageEdit").on("shown.bs.modal", function(){
89 $(".edit-patronimage").on("click", function(e){
91 var borrowernumber = $(this).data("borrowernumber");
92 var cardnumber = $(this).data("cardnumber");
93 var modalTitle = $(this).attr("title");
94 $("#patronImageEdit .modal-title").text(modalTitle);
95 $("#patronImageEdit").modal("show");
96 $("#patronImageEdit").on("hidden.bs.modal", function(){
97 /* Stop using the user's camera when modal is closed */
98 let viewfinder = document.getElementById("viewfinder");
99 if( viewfinder.srcObject ){
100 viewfinder.srcObject.getTracks().forEach( track => {
101 if( track.readyState == 'live' && track.kind === 'video'){
110 function searchfield_date_tooltip(filter) {
111 var field = "#searchmember" + filter;
112 var type = "#searchfieldstype" + filter;
113 if ( $(type).val() == 'dateofbirth' ) {
114 var MSG_DATE_FORMAT = "";
115 if( dateformat == 'us' ){
116 MSG_DATE_FORMAT = __("Dates of birth should be entered in the format 'MM/DD/YYYY'");
117 } else if( dateformat == 'iso' ){
118 MSG_DATE_FORMAT = __("Dates of birth should be entered in the format 'YYYY-MM-DD'");
119 } else if( dateformat == 'metric' ){
120 MSG_DATE_FORMAT = __("Dates of birth should be entered in the format 'DD/MM/YYYY'");
121 } else if( dateformat == 'dmydot' ){
122 MSG_DATE_FORMAT = __("Dates of birth should be entered in the format 'DD.MM.YYYY'");
124 $(field).attr("title", MSG_DATE_FORMAT).tooltip('show');
126 $(field).tooltip('destroy');
130 function confirm_updatechild() {
131 var is_confirmed = window.confirm( __("Are you sure you want to update this child to an Adult category? This cannot be undone.") );
133 window.location='/cgi-bin/koha/members/update-child.pl?op=update&borrowernumber=' + borrowernumber;
137 function update_child() {
138 if( number_of_adult_categories > 1 ){
139 window.open('/cgi-bin/koha/members/update-child.pl?op=multi&borrowernumber=' + borrowernumber,'UpdateChild','width=400,height=300,toolbar=no,scrollbars=yes,resizable=yes');
141 confirm_updatechild();
145 function confirm_reregistration() {
146 var is_confirmed = window.confirm( __("Are you sure you want to renew this patron's registration?") );
148 window.location = '/cgi-bin/koha/members/setstatus.pl?borrowernumber=' + borrowernumber + '&destination=' + destination + '&reregistration=y';
151 function export_barcodes() {
152 window.open('/cgi-bin/koha/members/readingrec.pl?borrowernumber=' + borrowernumber + '&op=export_barcodes');
154 var slip_re = /slip/;
155 function printx_window(print_type) {
156 var handler = print_type.match(slip_re) ? "printslip" : "summary-print";
157 window.open("/cgi-bin/koha/members/" + handler + ".pl?borrowernumber=" + borrowernumber + "&print=" + print_type, "printwindow");
160 function searchToHold(){
161 var date = new Date();
162 date.setTime(date.getTime() + (10 * 60 * 1000));
163 Cookies.set("holdfor", borrowernumber, { path: "/", expires: date, sameSite: 'Lax' });
164 location.href="/cgi-bin/koha/catalogue/search.pl";