Bug 6647: Label item search should use standard pagination routine
[koha.git] / koha-tmpl / intranet-tmpl / prog / en / modules / labels / result.tt
1 [% BLOCK pagination %]
2     <nav>
3         [% IF ( displayprev || displaynext ) %]
4             <ul class="pagination">
5                 [% IF ( displayprev ) %]
6                     <li><a class="nav" href="label-item-search.pl?startfrom=[% startfromprev %]&amp;ccl_query=[% ccl_query %]&amp;resultsperpage=[% resultsperpage %]&amp;op=do_search&amp;batch_id=[% batch_id %]"><i class="fa fa-arrow-left"></i> Previous</a></li>
7                 [% END %]
8                 [% FOREACH number IN numbers %]
9                     [% IF ( startfrom == number.startfrom ) %]
10                         <li class="active"><span>[% number.number %]</span></a></li>
11                     [% ELSE %]
12                         <li><a class="nav" href="label-item-search.pl?startfrom=[% number.startfrom %]&amp;ccl_query=[% ccl_query %]&amp;resultsperpage=[% resultsperpage %]&amp;op=do_search&amp;batch_id=[% batch_id %]">[% number.number %]</a></li>
13                     [% END %]
14                 [% END %]
15                 [% IF ( displaynext ) %]
16                     <li><a class="nav" href="label-item-search.pl?startfrom=[% startfromnext %]&amp;ccl_query=[% ccl_query %]&amp;resultsperpage=[% resultsperpage %]&amp;op=do_search&amp;batch_id=[% batch_id %]">Next <i class="fa fa-arrow-right"></i></a></li>
17                 [% END %]
18             </ul>
19         [% END %]
20     </nav>
21 [% END %]
22 [% USE Asset %]
23 [% SET footerjs = 1 %]
24     [% INCLUDE 'doc-head-open.inc' %]
25     <title>Koha &rsaquo; Barcodes and labels &rsaquo; Search results</title>
26     [% INCLUDE 'doc-head-close.inc' %]
27 </head>
28
29 <body id="labels_result" class="tools labels">
30     <div class="main container-fluid">
31             <h1>Search results</h1>
32         <div class="results">
33             [% PROCESS pagination %]
34                 [% IF ( results ) %]
35                 <strong>Results [% from %] through [% to %] [% IF ( total ) %] of [% total %][% END %]</strong>
36                 [% ELSE %]
37                 No results found
38                 [% END %]
39
40             <form name="resultform" action="">
41             <div id="toolbar" class="btn-toolbar">
42                 <div class="btn-group"><button type="button" class="btn btn-default btn-sm" id="add_items"><i class="fa fa-plus"></i> Add checked</button></div>
43                 <div class="btn-group"><a href="#" class="btn btn-default btn-sm close"><i class="fa fa-times-circle"></i> Done</a></div>
44             </div>
45                 <div><a id="CheckAll" href="#"><i class="fa fa-check"></i> Select all</a> <a id="CheckNone" href="#"><i class="fa fa-remove"></i> Clear all</a></div>
46
47                 <div id="label-search-results">
48                 <input type="hidden" name="ccl_query" value="[% ccl_query %]" />
49             [% FOREACH result_se IN result_set %]
50             <div style="border-bottom:1px solid #CCC;padding:1em 0;">
51                     <h4>[% result_se.title |html %]</h4>
52                             <p>[% IF ( result_se.author ) %]by [% result_se.author %][% END %]
53                             [[% result_se.itemtype %]], [% IF ( result_se.publishercode ) %][% result_se.publishercode %] [% END %][% IF ( result_se.place ) %][% result_se.place %] [% END %][% IF ( result_se.copyrightdate ) %][% result_se.copyrightdate %], [% END %][% IF ( result_se.pages ) %][% result_se.pages %][% END %][% IF ( result_se.isbn ) %], <b>ISBN: </b>[% result_se.isbn %][% END %][% IF ( result_se.notes ) %],<br />[% result_se.notes %][% END %]</p>
54
55                     <table>
56                     [% FOREACH item_tabl IN result_se.item_table %]
57                     [% IF ( item_tabl.header_fields ) %]
58                         <thead>
59                             <tr>
60                                 [% FOREACH header_field IN item_tabl.header_fields %]
61                                     [% SWITCH header_field.field_label -%]
62                                         [% CASE "Add Item" -%]
63                                             <th>Add item</th>
64                                         [% CASE "Call Number" -%]
65                                             <th>Call number</th>
66                                         [% CASE "Accession Date" %]
67                                             <th>Accession date</th>
68                                         [% CASE "Barcode" %]
69                                             <th>Barcode</th>
70                                         [% CASE "Select" -%]
71                                             <th>Select</th>
72                                         [% CASE %]
73                                             <th>[% header_field.field_label %]</th>
74                                     [% END -%]
75                                 [% END %]
76                             </tr>
77                         </thead>
78                     [% ELSE %]
79                     <tr>
80                     [% FOREACH text_field IN item_tabl.text_fields %]
81                     [% IF ( text_field.select_field ) %]
82                         <td><input type="checkbox" name="action" value="[% text_field.field_value %]"></td>
83                     [% ELSIF ( text_field.link_field ) %]
84                         <td>
85                             <a class="btn btn-default btn-xs select_item" data-item-number="[% text_field.field_value %]" data-batch-id="[% batch_id %]" data-field-type="[% text_field.type %]"><i class="fa fa-plus"></i> Add</a>
86                         </td>
87                     [% ELSE %]
88                         <td>[% text_field.field_value %]</td>
89                     [% END %]
90                     [% END %]
91                     </tr>
92                     [% END %]
93                     [% END %]
94                     </table>
95                     </div>
96             [% END %]
97                 </div>
98             </form>
99         </div>
100         [% PROCESS pagination %]
101         <div id="closewindow"><a href="#" class="btn btn-default btn-default close">Close</a></div>
102     </div>
103
104 [% MACRO jsinclude BLOCK %]
105     [% Asset.js("lib/jquery/plugins/jquery.fixFloat.js") %]
106     <script>
107         $(document).ready(function(){
108             $("#toolbar").fixFloat();
109             $("#CheckAll").click(function(e){
110                 e.preventDefault();
111                 $("input[type='checkbox']").prop("checked",true);
112             });
113             $("#CheckNone").click(function(e){
114                 e.preventDefault();
115                 $("input[type='checkbox']").prop("checked",false);
116             });
117             $("#add_items").on("click",function(){
118                 add_item('checked',[% batch_id %],'[% type %]');
119             });
120             $(".select_item").on("click",function(e){
121                 e.preventDefault();
122                 var batch_id = $(this).data("batch-id");
123                 var itemnumber = $(this).data("item-number");
124                 var type = $(this).data("field-type");
125                 add_item(itemnumber, batch_id, type);
126             });
127         });
128         function add_item(item_number,batch_id,type_id){
129             var p = window.opener;
130             if (item_number == 'checked') {
131                 items= new Array;
132                 if(document.resultform.action.length > 0) {
133                     for (var i=0; i < document.resultform.action.length; i++) {
134                         if (document.resultform.action[i].checked) {
135                             p.add_item(document.resultform.action[i].value);
136                         }
137                     }
138                 } else {
139                     p.add_item(document.resultform.action.value);
140                 }
141             }
142             else {
143                 p.add_item(item_number);
144             }
145         }
146     </script>
147 [% END %]
148
149 [% INCLUDE 'intranet-bottom.inc' popup_window=1 %]