Bug 26085: Add the copy, print and export DataTables buttons to lost items report
[koha.git] / koha-tmpl / intranet-tmpl / prog / en / modules / reports / itemslost.tt
1 [% USE raw %]
2 [% USE Asset %]
3 [% USE AuthorisedValues %]
4 [% USE Branches %]
5 [% USE TablesSettings %]
6 [% USE KohaDates %]
7 [% USE ItemTypes %]
8 [% USE Price %]
9 [% SET footerjs = 1 %]
10 [% INCLUDE 'doc-head-open.inc' %]
11 <title>Koha &rsaquo; Reports &rsaquo; Lost items</title>
12 [% INCLUDE 'doc-head-close.inc' %]
13 </head>
14
15 <body id="rep_itemslost" class="rep">
16 [% INCLUDE 'header.inc' %]
17 [% INCLUDE 'cat-search.inc' %]
18
19 <div id="breadcrumbs"><a href="/cgi-bin/koha/mainpage.pl">Home</a> &rsaquo; <a href="/cgi-bin/koha/reports/reports-home.pl">Reports</a>[% IF ( get_items ) %] &rsaquo; <a href="/cgi-bin/koha/reports/itemslost.pl">Lost items</a> &rsaquo; Results[% ELSE %] &rsaquo; Lost items[% END %]</div>
20
21 <div class="main container-fluid">
22     <div class="row">
23         <div class="col-sm-10 col-sm-push-2">
24             <main>
25
26
27 <h1>Lost items</h1>
28
29 [% IF ( get_items ) %]
30
31     [% IF items.count %]
32         [% IF csv_profiles.count %]
33             <div class="lostitems-table_table_controls">
34                 | <a href="#" class="SelectAll"><i class="fa fa-check"></i> Select all</a> |
35                 <a href="#" class="ClearAll"><i class="fa fa-remove"></i> Clear all</a>
36                 <span class="itemselection_actions">
37                     | Actions:
38                     <a class="itemselection_action_export"><i class="fa fa-download"></i> Export selected items</a>
39                     Using the following CSV profile:
40                     <select name="csv_profile_id" id="csv_profile_id">
41                         [% FOREACH csv_profile IN csv_profiles %]
42                             <option value="[% csv_profile.export_format_id | html %]">
43                                 [% csv_profile.profile | html %]
44                             </option>
45                         [% END %]
46                     </select>
47                 </span>
48             </div>
49         [% ELSE %]
50             <div class="dialog message">
51                 [% IF ( CAN_user_tools_manage_csv_profiles ) %]
52                     To enable the export of selected items, <a href="/cgi-bin/koha/tools/csv-profiles.pl">create a CSV profile</a> of the type "SQL" with usage option "Export lost items in report."
53                 [% ELSE %]
54                     To enable the export of selected items, your administrator must create a CSV profile of the type "SQL" with usage option "Export lost items in report."
55                 [% END %]
56             </div>
57             <div class="lostitems-table_table_controls">
58             </div>
59         [% END %]
60
61         <table id="lostitems-table">
62             <thead>
63                 <tr>
64                     [% IF csv_profiles.count %]
65                         <th class="NoSort"></th>
66                     [% END %]
67                     <th>Title</th>
68                     <th>Author</th>
69                     <th>Lost status</th>
70                     <th class="title-string">Lost on</th>
71                     <th>Barcode</th>
72                     <th>Call number</th>
73                     <th class="title-string">Date last seen</th>
74                     <th>Price</th>
75                     <th>Rep.price</th>
76                     <th>Library</th>
77                     <th>Item type</th>
78                     <th>Collection</th>
79                     <th>Current location</th>
80                     <th>Location</th>
81                     <th>Not for loan status</th>
82                     <th>Notes</th>
83                 </tr>
84             </thead>
85             <tbody>
86                 [% FOREACH item IN items %]
87                     <tr>
88                         [% IF csv_profiles.count %]
89                             <td style="text-align:center;vertical-align:middle">
90                                 <input type="checkbox" value="[% item.itemnumber | html %]" name="itemnumber" />
91                             </td>
92                         [% END %]
93                         <td>
94                             <a href="/cgi-bin/koha/catalogue/detail.pl?biblionumber=[% item.biblionumber | uri %]">[% item.biblio.title | html %]</a>
95                         </td>
96                         <td>[% item.biblio.author | html %]</td>
97                         <td>[% AuthorisedValues.GetDescriptionByKohaField( kohafield => 'items.itemlost', authorised_value => item.itemlost ) | html %]
98                         <td><span title="[% item.itemlost_on | html %]">[% item.itemlost_on | $KohaDates %]</span></td>
99                         <td>
100                             <a href="/cgi-bin/koha/catalogue/moredetail.pl?biblionumber=[% item.biblionumber | uri %]">[% item.barcode | html %]</a>
101                         </td>
102                         <td>[% item.itemcallnumber | html %]</td>
103                         <td><span title="[% item.datelastseen | html %]">[% item.datelastseen | $KohaDates %]</span></td>
104                         <td>[% item.price | $Price %]</td>
105                         <td>[% item.replacementprice | $Price %]</td>
106                         <td>[% Branches.GetName(item.homebranch) | html %]</td>
107                         <td>[% ItemTypes.GetDescription(item.effective_itemtype) | html %]</td>
108                         <td>[% AuthorisedValues.GetByCode( 'CCODE', item.ccode ) | html %]</td>
109                         <td>[% Branches.GetName(item.holdingbranch) | html %]</td>
110                         <td>[% AuthorisedValues.GetByCode( 'LOC', item.location ) | html %]</td>
111                         <td>[% AuthorisedValues.GetDescriptionByKohaField( kohafield => 'items.notforloan', authorised_value => item.notforloan ) | html %]
112                         <td>[% item.itemnotes | $raw %]</td>
113                     </tr>
114                 [% END %]
115             </tbody>
116         </table>
117     [% END %]
118         [% ELSE %]
119         
120         <form name="f" action="/cgi-bin/koha/reports/itemslost.pl" method="post">
121     <fieldset class="rows">
122         <ol>
123
124         <li><label for="barcodefilter">Barcode: </label><input type="text" name="barcodefilter" id="barcodefilter" size="6" /></li>
125         <li><label for="branchfilter">Library: </label><select name="branchfilter" id="branchfilter">
126                 <option value="">All</option>
127                 [% PROCESS options_for_libraries libraries => Branches.all() %]
128             </select></li>
129     <li><label for="itemtypesfilter">Item type: </label><select name="itemtypesfilter" id="itemtypesfilter">
130                 <option value="">All</option>
131                 [% FOREACH itemtype IN itemtypes %]
132                     <option value="[% itemtype.itemtype | html %]">[% itemtype.translated_description | html %]</option>
133                 [% END %]
134             </select></li>
135
136     <li>
137         <label for="loststatusfilter">Lost status: </label>
138         <select name="loststatusfilter" id="loststatusfilter">
139             <option value="">All</option>
140             [% FOREACH l IN AuthorisedValues.GetDescriptionsByKohaField( kohafield => 'items.itemlost') %]
141                 [% IF l.authorised_value == lostfilter %]
142                     <option value="[% l.authorised_value | html %]" selected="selected">[% l.lib | html %]</option>
143                 [% ELSE %]
144                     <option value="[% l.authorised_value | html %]">[% l.lib | html %]</option>
145                 [% END %]
146             [% END %]
147         </select>
148     </li>
149
150     <li>
151         <label for="notforloanfilter">Not for loan: </label>
152         <select name="notforloanfilter" id="notforloanfilter">
153             <option value="">All</option>
154             [% FOREACH n IN AuthorisedValues.GetDescriptionsByKohaField( kohafield => 'items.notforloan') %]
155                 [% IF n.authorised_value == notforloanfilter %]
156                     <option value="[% n.authorised_value | html %]" selected="selected">[% n.lib | html %]</option>
157                 [% ELSE %]
158                     <option value="[% n.authorised_value | html %]">[% n.lib | html %]</option>
159                 [% END %]
160             [% END %]
161         </select>
162     </li>
163
164 </ol></fieldset>
165 <fieldset class="action">    <input type="submit" value="Submit" />
166     <input type="hidden" name="get_items" value="1" /></fieldset>
167 </form>
168         
169         [% END %]
170
171             </main>
172         </div> <!-- /.col-sm-10.col-sm-push-2 -->
173
174         <div class="col-sm-2 col-sm-pull-10">
175             <aside>
176                 [% INCLUDE 'reports-menu.inc' %]
177             </aside>
178         </div> <!-- /.col-sm-2.col-sm-pull-10 -->
179      </div> <!-- /.row -->
180
181 [% MACRO jsinclude BLOCK %]
182     [% INCLUDE 'datatables.inc' %]
183     [% Asset.js("lib/jquery/plugins/jquery.dataTables.columnFilter.js") | $raw %]
184     [% INCLUDE 'columns_settings.inc' %]
185     [% Asset.js("js/table_filters.js") | $raw %]
186     [% Asset.js("lib/jquery/plugins/jquery.checkboxes.min.js") | $raw %]
187     <script>
188         $(document).ready(function() {
189             var columns_settings = [% TablesSettings.GetColumns( 'reports', 'lostitems', 'lostitems-table', 'json' ) | $raw %];
190             var lostitems_table = KohaTable("lostitems-table", {
191                 "aaSorting": [],
192                 "aoColumnDefs": [
193                     { "bSortable": false, "bSearchable": false, 'aTargets': [ 'NoSort' ] },
194                     { "sType": "title-string", "aTargets" : [ "title-string" ] }
195                 ],
196                 'bAutoWidth': false,
197                 "bPaginate": false,
198             }, columns_settings, 'with_filters');
199
200             function itemSelectionBuildExportLink() {
201                 var itemnumbers = new Array();
202                 $("input[name='itemnumber'][type='checkbox']:checked").each(function() {
203                     itemnumbers.push($(this).val());
204                 });
205                 if (itemnumbers.length > 0) {
206                     var csv_profile_id = $("#csv_profile_id  option:selected").val();
207                     var url = '/cgi-bin/koha/reports/itemslost.pl?op=export&csv_profile_id='+csv_profile_id;
208                     url += '&itemnumber=' + itemnumbers.join('&itemnumber=');
209                     $('a.itemselection_action_export').attr('href', url);
210                 } else {
211                     return false;
212                 }
213                 return true;
214             }
215
216             function itemSelectionBuildActionLinks() {
217                 var export_link_ok = itemSelectionBuildExportLink();
218                 if (export_link_ok) {
219                     $('.itemselection_actions').show();
220                 } else {
221                     $('.itemselection_actions').hide();
222                 }
223             }
224
225             itemSelectionBuildActionLinks();
226
227             $("input[name='itemnumber'][type='checkbox']").change(function() {
228                 itemSelectionBuildActionLinks();
229             });
230             $("#csv_profile_id").change(function() {
231                 itemSelectionBuildActionLinks();
232             });
233
234             $(".SelectAll").on("click",function(e){
235                 e.preventDefault();
236                 $("#lostitems-table").checkCheckboxes();
237                 itemSelectionBuildActionLinks();
238             });
239
240             $(".ClearAll").on("click",function(e){
241                 e.preventDefault();
242                 $("#lostitems-table").unCheckCheckboxes();
243                 itemSelectionBuildActionLinks();
244             });
245         });
246     </script>
247 [% END %]
248
249 [% INCLUDE 'intranet-bottom.inc' %]