Bug 29648: ILL - no change
[koha.git] / koha-tmpl / intranet-tmpl / prog / js / pages / circulation.js
1 /* global flatpickr_dateformat_string flatpickr_timeformat_string */
2 $(document).ready(function() {
3     $("#CheckAllExports").on("click",function(){
4         $(".export:visible").prop("checked", true);
5         return false;
6     });
7     $("#UncheckAllExports").on("click",function(){
8         $(".export:visible").prop("checked", false);
9         return false;
10     });
11
12     $('#patronlists').tabs({
13         activate: function( event, ui ) {
14             $("a", ui.newTab ).click();
15         }
16     });
17
18     $("#borrower_messages .cancel").on("click",function(){
19         $("#add_message_form").hide();
20         $("#addmessage").show();
21     });
22
23     $("#addmessage").on("click",function(){
24         $(this).hide();
25         $("#add_message_form").show();
26      });
27
28     $("input.radio").on("click",function(){
29         radioCheckBox($(this));
30     });
31
32     $("#duedatespec").flatpickr({
33         enableTime: true,
34         dateFormat: flatpickr_dateformat_string + " " + flatpickr_timeformat_string,
35         onClose: function() {
36             $("#barcode").focus();
37         }
38     });
39
40     $("#newduedate, #newonholdduedate input").flatpickr({
41         enableTime: true,
42         dateFormat: flatpickr_dateformat_string + " " + flatpickr_timeformat_string,
43     });
44
45     $(".clear_date").on("click", function(){
46         $("#stickyduedate").prop( "checked", false );
47     });
48
49     $("#export_submit").on("click",function(){
50         export_checkouts($("#issues-table-output-format").val());
51         return false;
52     });
53
54     var circ_settings = $(".circ-settings");
55     var circ_settings_icon = $(".circ-settings-icon");
56
57     // If any checkboxes in the circ settings are selected, show the settings by default
58     if ( $(".circ-settings input:checked,#duedatespec[value!='']").length ) {
59         circ_settings.show();
60         circ_settings_icon.removeClass("fa-caret-right").addClass("fa-caret-down");
61     } else {
62         circ_settings.hide();
63         circ_settings_icon.removeClass("fa-caret-down").addClass("fa-caret-right");
64     }
65
66     $("#show-circ-settings a").on("click",function(){
67         if( circ_settings.is(":hidden")){
68             circ_settings.show();
69             circ_settings_icon.removeClass("fa-caret-right").addClass("fa-caret-down");
70         } else {
71             $("#barcode").focus();
72             circ_settings.hide();
73             circ_settings_icon.removeClass("fa-caret-down").addClass("fa-caret-right");
74         }
75     });
76
77     $(".circ_setting").on("click",function(){
78         $("#barcode").focus();
79     });
80
81     $("#itemSearchFallback").ready(function(){
82         $("#itemSearchFallback").modal("show");
83     });
84
85     // Debarments
86     $("div#reldebarments .remove_restriction").on("click",function(){
87         return confirm( __("Remove restriction?") );
88     });
89     var mrform = $("#manual_restriction_form");
90     var mrlink = $("#add_manual_restriction");
91     mrform.hide();
92     mrlink.on("click",function(e){
93         $(this).hide();
94         mrform.show();
95         e.preventDefault();
96     });
97     $("#cancel_manual_restriction").on("click",function(e){
98         mrlink.show();
99         mrform.hide();
100         e.preventDefault();
101     });
102     $(".clear-date").on("click",function(e){
103         e.preventDefault();
104         var fieldID = this.id.replace("clear-date-","");
105         $("#" + fieldID).val("");
106     });
107
108
109 });
110
111 function export_checkouts(format) {
112     if ($("input:checkbox[name='biblionumbers']:checked").length < 1){
113         alert( __("You must select checkout(s) to export") );
114         return;
115     }
116
117     $("input:checkbox[name='biblionumbers']").each( function(){
118         var input_item = $(this).siblings("input:checkbox");
119         if ( $(this).is(":checked") ) {
120             $(input_item).prop("checked", true);
121         } else {
122             $(input_item).prop("checked", false);
123         }
124     } );
125
126     if (format == 'iso2709_995') {
127         format = 'iso2709';
128         $("#dont_export_item").val(0);
129     } else if (format == 'iso2709') {
130         $("#dont_export_item").val(1);
131     }
132
133     document.getElementById("output_format").value = format;
134     document.issues.submit();
135 }