Bug 16242 - Move staff client JavaScript out of language directory
[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     $("#messages ul").after("<a href=\"#\" id=\"addmessage\">"+MSG_ADD_MESSAGE+"</a>");
18
19     $("#borrower_messages .cancel").on("click",function(){
20         $("#add_message_form").hide();
21         $("#addmessage").show();
22     });
23
24     $("#addmessage").on("click",function(){
25         $(this).hide();
26         $("#add_message_form").show();
27      });
28
29     $("input.radio").on("click",function(){
30         radioCheckBox($(this));
31     });
32
33     $("#newduedate").datetimepicker({
34         minDate: 1, // require that renewal date is after today
35         hour: 23,
36         minute: 59
37     });
38     $("#duedatespec").datetimepicker({
39         onClose: function(dateText, inst) { $("#barcode").focus(); },
40         hour: 23,
41         minute: 59
42     });
43     $("#export_submit").on("click",function(){
44         var output_format = $("#output_format").val();
45         export_checkouts(output_format);
46         return false;
47     });
48
49     var checkout_settings = $(".checkout-settings");
50     var checkout_settings_icon = $(".checkout-settings-icon");
51
52     // If any checkboxes in the checkout settings are selected, show the settings by default
53     if ( $(".checkout-settings input:checked,#duedatespec[value!='']").length ) {
54         checkout_settings.show();
55         checkout_settings_icon.removeClass("fa-caret-right").addClass("fa-caret-down");
56     } else {
57         checkout_settings.hide();
58         checkout_settings_icon.removeClass("fa-caret-down").addClass("fa-caret-right");
59     }
60
61     $("#show-checkout-settings a").on("click",function(){
62         if( checkout_settings.is(":hidden")){
63             checkout_settings.show();
64             checkout_settings_icon.removeClass("fa-caret-right").addClass("fa-caret-down");
65         } else {
66             $("#barcode").focus();
67             checkout_settings.hide();
68             checkout_settings_icon.removeClass("fa-caret-down").addClass("fa-caret-right");
69         }
70     });
71
72 });
73
74 function export_checkouts(format) {
75     if ($("input:checkbox[name='biblionumbers']:checked").length < 1){
76         alert(MSG_EXPORT_SELECT_CHECKOUTS);
77         return;
78     }
79
80     $("input:checkbox[name='biblionumbers']").each( function(){
81         var input_item = $(this).siblings("input:checkbox");
82         if ( $(this).is(":checked") ) {
83             $(input_item).prop("checked", true);
84         } else {
85             $(input_item).prop("checked", false);
86         }
87     } );
88
89     if (format == 'iso2709_995') {
90         format = 'iso2709';
91         $("#dont_export_item").val(0);
92     } else if (format == 'iso2709') {
93         $("#dont_export_item").val(1);
94     }
95
96     document.getElementById("output_format").value = format;
97     document.issues.submit();
98 }
99
100 function validate1(date) {
101     var today = new Date();
102     if ( date < today ) {
103         return true;
104      } else {
105         return false;
106      }
107 }