Bug 3669: Moving 'Add a new message' into a pop up box and adding to patron toolbar
[koha.git] / koha-tmpl / intranet-tmpl / prog / js / pages / circulation.js
1 $(document).ready(function() {
2     $("#CheckAllExports").on("click",function(){
3         $(".export:visible").prop("checked", true);
4         return false;
5     });
6     $("#UncheckAllExports").on("click",function(){
7         $(".export:visible").prop("checked", false);
8         return false;
9     });
10
11     $('#patronlists').tabs({
12         activate: function( event, ui ) {
13             $('#'+ui.newTab.context.id).click();
14         }
15     });
16
17     $("#borrower_messages .cancel").on("click",function(){
18         $("#add_message_form").hide();
19         $("#addmessage").show();
20     });
21
22     $("#addmessage").on("click",function(){
23         $(this).hide();
24         $("#add_message_form").show();
25      });
26
27     $("input.radio").on("click",function(){
28         radioCheckBox($(this));
29     });
30
31     $("#newduedate").datetimepicker({
32         minDate: 1, // require that renewal date is after today
33         hour: 23,
34         minute: 59
35     });
36     $("#duedatespec").datetimepicker({
37         onClose: function(dateText, inst) { $("#barcode").focus(); },
38         hour: 23,
39         minute: 59
40     });
41     $("#export_submit").on("click",function(){
42         var output_format = $("#output_format").val();
43         export_checkouts(output_format);
44         return false;
45     });
46
47     var checkout_settings = $(".checkout-settings");
48     var checkout_settings_icon = $(".checkout-settings-icon");
49
50     // If any checkboxes in the checkout settings are selected, show the settings by default
51     if ( $(".checkout-settings input:checked,#duedatespec[value!='']").length ) {
52         checkout_settings.show();
53         checkout_settings_icon.removeClass("fa-caret-right").addClass("fa-caret-down");
54     } else {
55         checkout_settings.hide();
56         checkout_settings_icon.removeClass("fa-caret-down").addClass("fa-caret-right");
57     }
58
59     $("#show-checkout-settings a").on("click",function(){
60         if( checkout_settings.is(":hidden")){
61             checkout_settings.show();
62             checkout_settings_icon.removeClass("fa-caret-right").addClass("fa-caret-down");
63         } else {
64             $("#barcode").focus();
65             checkout_settings.hide();
66             checkout_settings_icon.removeClass("fa-caret-down").addClass("fa-caret-right");
67         }
68     });
69
70 });
71
72 function export_checkouts(format) {
73     if ($("input:checkbox[name='biblionumbers']:checked").length < 1){
74         alert(MSG_EXPORT_SELECT_CHECKOUTS);
75         return;
76     }
77
78     $("input:checkbox[name='biblionumbers']").each( function(){
79         var input_item = $(this).siblings("input:checkbox");
80         if ( $(this).is(":checked") ) {
81             $(input_item).prop("checked", true);
82         } else {
83             $(input_item).prop("checked", false);
84         }
85     } );
86
87     if (format == 'iso2709_995') {
88         format = 'iso2709';
89         $("#dont_export_item").val(0);
90     } else if (format == 'iso2709') {
91         $("#dont_export_item").val(1);
92     }
93
94     document.getElementById("output_format").value = format;
95     document.issues.submit();
96 }
97
98 function validate1(date) {
99     var today = new Date();
100     if ( date < today ) {
101         return true;
102      } else {
103         return false;
104      }
105 }