Bug 17344 - Can't set guarantor in quick add brief form
[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         onClose: function(dateText, inst) {
33             validate_date(dateText, inst);
34         },
35         minDate: 1, // require that renewal date is after today
36         hour: 23,
37         minute: 59
38     }).on("change", function(e) {
39         if ( ! is_valid_date( $(this).val() ) ) {$(this).val("");}
40     });
41     $("#duedatespec").datetimepicker({
42         onClose: function(dateText, inst) {
43             if ( validate_date(dateText, inst) ) {
44                 $("#barcode").focus();
45             }
46         },
47         hour: 23,
48         minute: 59
49     }).on("change", function(e, value) {
50         if ( ! is_valid_date( $(this).val() ) ) {$(this).val("");}
51     });
52     $("#export_submit").on("click",function(){
53         export_checkouts($("#issues-table-output-format").val());
54         return false;
55     });
56
57     var checkout_settings = $(".checkout-settings");
58     var checkout_settings_icon = $(".checkout-settings-icon");
59
60     // If any checkboxes in the checkout settings are selected, show the settings by default
61     if ( $(".checkout-settings input:checked,#duedatespec[value!='']").length ) {
62         checkout_settings.show();
63         checkout_settings_icon.removeClass("fa-caret-right").addClass("fa-caret-down");
64     } else {
65         checkout_settings.hide();
66         checkout_settings_icon.removeClass("fa-caret-down").addClass("fa-caret-right");
67     }
68
69     $("#show-checkout-settings a").on("click",function(){
70         if( checkout_settings.is(":hidden")){
71             checkout_settings.show();
72             checkout_settings_icon.removeClass("fa-caret-right").addClass("fa-caret-down");
73         } else {
74             $("#barcode").focus();
75             checkout_settings.hide();
76             checkout_settings_icon.removeClass("fa-caret-down").addClass("fa-caret-right");
77         }
78     });
79
80 });
81
82 function export_checkouts(format) {
83     if ($("input:checkbox[name='biblionumbers']:checked").length < 1){
84         alert(MSG_EXPORT_SELECT_CHECKOUTS);
85         return;
86     }
87
88     $("input:checkbox[name='biblionumbers']").each( function(){
89         var input_item = $(this).siblings("input:checkbox");
90         if ( $(this).is(":checked") ) {
91             $(input_item).prop("checked", true);
92         } else {
93             $(input_item).prop("checked", false);
94         }
95     } );
96
97     if (format == 'iso2709_995') {
98         format = 'iso2709';
99         $("#dont_export_item").val(0);
100     } else if (format == 'iso2709') {
101         $("#dont_export_item").val(1);
102     }
103
104     document.getElementById("output_format").value = format;
105     document.issues.submit();
106 }
107
108 function validate1(date) {
109     var today = new Date();
110     if ( date < today ) {
111         return true;
112      } else {
113         return false;
114      }
115 }