Bug 9294: Followup : add missing lines.
[koha.git] / koha-tmpl / intranet-tmpl / prog / en / js / pages / circulation.js
1 $(document).ready(function() {
2     $('#patronlists').tabs();
3     var allcheckboxes = $(".checkboxed");
4     $("#renew_all").on("click",function(){
5         allcheckboxes.checkCheckboxes(":input[name*=items]");
6         allcheckboxes.unCheckCheckboxes(":input[name*=barcodes]");
7     });
8     $("#CheckAllitems").on("click",function(){
9         allcheckboxes.checkCheckboxes(":input[name*=items]");
10         allcheckboxes.unCheckCheckboxes(":input[name*=barcodes]"); return false;
11     });
12     $("#CheckNoitems").on("click",function(){
13         allcheckboxes.unCheckCheckboxes(":input[name*=items]"); return false;
14     });
15     $("#CheckAllreturns").on("click",function(){
16         allcheckboxes.checkCheckboxes(":input[name*=barcodes]");
17         allcheckboxes.unCheckCheckboxes(":input[name*=items]"); return false;
18     });
19     $("#CheckNoreturns" ).on("click",function(){
20         allcheckboxes.unCheckCheckboxes(":input[name*=barcodes]"); return false;
21     });
22
23     $("#CheckAllexports").on("click",function(){
24         allcheckboxes.checkCheckboxes(":input[name*=biblionumbers]");
25         allcheckboxes.unCheckCheckboxes(":input[name*=items]");
26         return false;
27     });
28     $("#CheckNoexports").on("click",function(){
29         allcheckboxes.unCheckCheckboxes(":input[name*=biblionumbers]");
30         return false;
31     });
32
33     $("#relrenew_all").on("click",function(){
34         allcheckboxes.checkCheckboxes(":input[name*=items]");
35         allcheckboxes.unCheckCheckboxes(":input[name*=barcodes]");
36     });
37     $("#relCheckAllitems").on("click",function(){
38         allcheckboxes.checkCheckboxes(":input[name*=items]");
39         allcheckboxes.unCheckCheckboxes(":input[name*=barcodes]"); return false;
40     });
41     $("#relCheckNoitems").on("click",function(){
42         allcheckboxes.unCheckCheckboxes(":input[name*=items]"); return false;
43     });
44     $("#relCheckAllreturns").on("click",function(){
45         allcheckboxes.checkCheckboxes(":input[name*=barcodes]");
46         allcheckboxes.unCheckCheckboxes(":input[name*=items]"); return false;
47     });
48     $("#relCheckNoreturns").on("click",function(){
49         allcheckboxes.unCheckCheckboxes(":input[name*=barcodes]"); return false;
50     });
51     $("#messages ul").after("<a href=\"#\" id=\"addmessage\">"+MSG_ADD_MESSAGE+"</a>");
52     $("#borrower_messages .cancel").on("click",function(){
53         $("#add_message_form").hide();
54         $("#addmessage").show();
55     });
56     $("#addmessage").on("click",function(){
57         $(this).hide();
58         $("#add_message_form").show();
59      });
60
61     $("input.radio").on("click",function(){
62         radioCheckBox($(this));
63     });
64
65     $("#newduedate").datetimepicker({
66         minDate: 1, // require that renewal date is after today
67         hour: 23,
68         minute: 59
69     });
70     $("#duedatespec").datetimepicker({
71         onClose: function(dateText, inst) { $("#barcode").focus(); },
72         hour: 23,
73         minute: 59
74     });
75     $("#export_submit").on("click",function(){
76         var export_format = $("#export_formats").val();
77         export_checkouts(export_format);
78         return false;
79     });
80     // Clicking the table cell checks the checkbox inside it
81     $("td").on("click",function(e){
82         if(e.target.tagName.toLowerCase() == 'td'){
83            $(this).find("input:checkbox:visible").each( function() {
84                 if($(this).attr("checked")){
85                     $(this).removeAttr("checked");
86                 } else {
87                     $(this).attr("checked","checked");
88                     radioCheckBox($(this));
89                 }
90            });
91         }
92     });
93 });
94
95 function export_checkouts(format) {
96     if ($("input:checkbox[name='biblionumbers'][checked]").length < 1){
97         alert(MSG_EXPORT_SELECT_CHECKOUTS);
98         return;
99     }
100
101     $("input:checkbox[name='biblionumbers']").each( function(){
102         var input_item = $(this).siblings("input:checkbox");
103         if ( $(this).is(":checked") ) {
104             $(input_item).attr("checked", "checked");
105         } else {
106             $(input_item).attr("checked", "");
107         }
108     } );
109
110     if (format == 'iso2709_995') {
111         format = 'iso2709';
112         $("#dont_export_item").val(0);
113     } else if (format == 'iso2709') {
114         $("#dont_export_item").val(1);
115     }
116     document.issues.action="/cgi-bin/koha/tools/export.pl";
117     document.getElementById("export_format").value = format;
118     document.issues.submit();
119
120     /* Reset form action to its initial value */
121     document.issues.action="/cgi-bin/koha/reserve/renewscript.pl";
122
123 }
124
125 function validate1(date) {
126     var today = new Date();
127     if ( date < today ) {
128         return true;
129      } else {
130         return false;
131      }
132 }
133
134 // prevent adjacent checkboxes from being checked simultaneously
135 function radioCheckBox(box){
136     box.parents("td").siblings().find("input:checkbox:visible").each(function(){
137         if($(this).attr("checked")){
138             $(this).removeAttr("checked");
139         }
140     });
141  }