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 $("#updatechild, #patronflags, #renewpatron, #deletepatron, #exportbarcodes").tooltip();
51 $("#exportcheckins").click(function(){
53 $(".btn-group").removeClass("open");
56 $("#printsummary").click(function(){
57 printx_window("page");
58 $(".btn-group").removeClass("open");
61 $("#printslip").click(function(){
62 printx_window("slip");
63 $(".btn-group").removeClass("open");
66 $("#printquickslip").click(function(){
67 printx_window("qslip");
68 $(".btn-group").removeClass("open");
71 $("#print_overdues").click(function(){
72 window.open("/cgi-bin/koha/members/print_overdues.pl?borrowernumber=" + borrowernumber, "printwindow");
73 $(".btn-group").removeClass("open");
76 $("#printcheckinslip").click(function(){
77 printx_window("checkinslip");
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 $("#patronImageEdit").on("shown.bs.modal", function(){
97 $(".edit-patronimage").on("click", function(e){
99 var borrowernumber = $(this).data("borrowernumber");
100 var cardnumber = $(this).data("cardnumber");
101 var modalTitle = $(this).attr("title");
102 $("#patronImageEdit .modal-title").text(modalTitle);
103 $("#patronImageEdit").modal("show");
104 $("#patronImageEdit").on("hidden.bs.modal", function(){
105 /* Stop using the user's camera when modal is closed */
106 let viewfinder = document.getElementById("viewfinder");
107 if( viewfinder.srcObject ){
108 viewfinder.srcObject.getTracks().forEach( track => {
109 if( track.readyState == 'live' && track.kind === 'video'){
118 function searchfield_date_tooltip(filter) {
119 var field = "#searchmember" + filter;
120 var type = "#searchfieldstype" + filter;
121 if ( $(type).val() == 'dateofbirth' ) {
122 var MSG_DATE_FORMAT = "";
123 if( dateformat == 'us' ){
124 MSG_DATE_FORMAT = __("Dates of birth should be entered in the format 'MM/DD/YYYY'");
125 } else if( dateformat == 'iso' ){
126 MSG_DATE_FORMAT = __("Dates of birth should be entered in the format 'YYYY-MM-DD'");
127 } else if( dateformat == 'metric' ){
128 MSG_DATE_FORMAT = __("Dates of birth should be entered in the format 'DD/MM/YYYY'");
129 } else if( dateformat == 'dmydot' ){
130 MSG_DATE_FORMAT = __("Dates of birth should be entered in the format 'DD.MM.YYYY'");
132 $(field).attr("title", MSG_DATE_FORMAT).tooltip('show');
134 $(field).tooltip('destroy');
138 function confirm_updatechild() {
139 var is_confirmed = window.confirm( __("Are you sure you want to update this child to an Adult category? This cannot be undone.") );
141 window.location='/cgi-bin/koha/members/update-child.pl?op=update&borrowernumber=' + borrowernumber;
145 function update_child() {
146 if( number_of_adult_categories > 1 ){
147 window.open('/cgi-bin/koha/members/update-child.pl?op=multi&borrowernumber=' + borrowernumber,'UpdateChild','width=400,height=300,toolbar=no,scrollbars=yes,resizable=yes');
149 confirm_updatechild();
153 function confirm_reregistration() {
154 var is_confirmed = window.confirm( __("Are you sure you want to renew this patron's registration?") );
156 window.location = '/cgi-bin/koha/members/setstatus.pl?borrowernumber=' + borrowernumber + '&destination=' + destination + '&reregistration=y';
159 function export_barcodes() {
160 window.open('/cgi-bin/koha/members/readingrec.pl?borrowernumber=' + borrowernumber + '&op=export_barcodes');
162 var slip_re = /slip/;
163 function printx_window(print_type) {
164 var handler = print_type.match(slip_re) ? "printslip" : "summary-print";
165 window.open("/cgi-bin/koha/members/" + handler + ".pl?borrowernumber=" + borrowernumber + "&print=" + print_type, "printwindow");
168 function searchToHold(){
169 var date = new Date();
170 date.setTime(date.getTime() + (10 * 60 * 1000));
171 Cookies.set("holdfor", borrowernumber, { path: "/", expires: date });
172 location.href="/cgi-bin/koha/catalogue/search.pl";