Bug 14919: (followup) Show accurate status in holds history
[koha.git] / koha-tmpl / intranet-tmpl / prog / js / cart.js
1
2 function placeHold () {
3     var checkedItems = $("input:checkbox:checked");
4     if ($(checkedItems).size() === 0) {
5         alert(MSG_NO_RECORD_SELECTED);
6         return false;
7     }
8
9     var newloc;
10
11     if ($(checkedItems).size() > 1) {
12         var bibs = "";
13         $(checkedItems).each(function() {
14             var bib = $(this).val();
15             bibs += bib + "/";
16         });
17
18         newloc = "/cgi-bin/koha/reserve/request.pl?biblionumbers=" + bibs + "&multi_hold=1";
19     } else {
20         var bib = checkedItems[0].value;
21         newloc = "/cgi-bin/koha/reserve/request.pl?biblionumber=" + bib;
22     }
23
24     window.opener.location = newloc;
25     window.close();
26 }
27
28 function batchDelete(){
29     var checkedItems = $("input:checkbox:checked");
30     if ($(checkedItems).size() === 0) {
31         alert(MSG_NO_RECORD_SELECTED);
32         return false;
33     }
34     var newloc;
35
36     var bibs = "";
37     checkedItems.each(function() {
38         var bib = $(this).val();
39         bibs += bib + "/";
40     });
41
42     newloc = "/cgi-bin/koha/tools/batch_delete_records.pl?op=list&type=biblio&bib_list=" + bibs;
43
44     window.opener.location = newloc;
45     window.close();
46 }
47
48 function batchModify(){
49     var checkedItems = $("input:checkbox:checked");
50     if ($(checkedItems).size() === 0) {
51         alert(MSG_NO_RECORD_SELECTED);
52         return false;
53     }
54     var newloc;
55
56     var bibs = "";
57     $(checkedItems).each(function() {
58         var bib = $(this).val();
59         bibs += bib + "/";
60     });
61     newloc = "/cgi-bin/koha/tools/batch_record_modification.pl?op=list&bib_list=" + bibs + "&type=biblio";
62
63     window.opener.location = newloc;
64     window.close();
65 }
66
67 $(document).ready(function(){
68     $("#items-popover").popover();
69     $("#CheckAll").click(function(){
70     var checked = [];
71     $("#bookbag_form").checkCheckboxes("*", true).each(
72         function() {
73             selRecord(this.value,true);
74         }
75     );
76         return false;
77     });
78     $("#CheckNone").click(function(){
79     var checked = [];
80     $("#bookbag_form").unCheckCheckboxes("*",true).each(
81         function() {
82             selRecord(this.value,false);
83         }
84     );
85         return false;
86     });
87     $(".holdsep").text("| ");
88     $(".hold").text(_("Place hold"));
89     $("#downloadcartc").empty();
90
91     $("#itemst").dataTable($.extend(true, {}, dataTablesDefaults, {
92         "sDom": 't',
93         "aoColumnDefs": [
94             { "bSortable": false, "bSearchable": false, 'aTargets': [ 'NoSort' ] },
95             { "sType": "anti-the", "aTargets" : [ "anti-the" ] },
96             { "sType": "callnumbers", "aTargets" : [ "callnumbers"] }
97         ],
98         "aaSorting": [[ 1, "asc" ]],
99         "bPaginate": false
100     }));
101
102     $(".showdetails").on("click",function(e){
103         e.preventDefault();
104         if( $(this).hasClass("showmore") ){
105             showMore();
106         } else {
107             showLess();
108         }
109     });
110
111     $("#batch_modify").on("click",function(e){
112         e.preventDefault();
113         batchModify();
114     });
115     $("#batch_delete").on("click",function(e){
116         e.preventDefault();
117         batchDelete();
118     });
119
120     $("#remove_from_cart").on("click",function(e){
121         e.preventDefault();
122         delSelRecords();
123     });
124
125     $("#add_to_list").on("click",function(e){
126         e.preventDefault();
127         addSelToShelf();
128     });
129
130     $("#place_hold").on("click",function(e){
131         e.preventDefault();
132         placeHold();
133     });
134
135     $("#send_cart").on("click",function(e){
136         e.preventDefault();
137         sendBasket();
138     });
139
140     $("#print_cart").on("click",function(e){
141         e.preventDefault();
142         printBasket();
143     });
144
145     $("#empty_cart").on("click",function(e){
146         e.preventDefault();
147         delBasket('popup');
148     });
149     $(".open_title").on("click",function(e){
150         e.preventDefault();
151         openBiblio( this.href );
152     });
153     $(".select_record").on("change",function(){
154         selRecord( this.value, this.checked );
155     });
156 });