Bug 19021: Fix Inventory columns sorting
[koha.git] / koha-tmpl / intranet-tmpl / prog / en / modules / tools / inventory.tt
1 [% USE KohaDates %]
2 [% USE Branches %]
3 [% INCLUDE 'doc-head-open.inc' %]
4 <title>Koha &rsaquo; Tools &rsaquo; Inventory</title>
5 [% INCLUDE 'doc-head-close.inc' %]
6 <link rel="stylesheet" type="text/css" href="[% interface %]/[% theme %]/css/datatables.css" />
7 [% INCLUDE 'datatables.inc' %]
8 [% INCLUDE 'calendar.inc' %]
9 <script type="text/javascript" src="[% interface %]/lib/jquery/plugins/jquery.checkboxes.min.js"></script>
10 <script type="text/javascript">
11 //<![CDATA[
12 function checkForm() {
13     if ( $('#uploadbarcodes').val() ) {
14         if ( !(
15             $('#branchloop').val()   ||
16             $('#locationloop').val() ||
17             $('#minlocation').val()  ||
18             $('#maxlocation').val()  ||
19             $('#statuses input:checked').length
20         ) ) {
21             return confirm(
22                 _("You have not selected any catalog filters and are about to compare a file of barcodes to your entire catalog.") + "\n\n" +
23                 _("For large catalogs this can result in unexpected behavior") + "\n\n" +
24                 _("Are you sure you want to do this?")
25             );
26         }
27     }
28
29     return true;
30 }
31
32 $(document).ready(function(){
33         inventorydt = $('#inventoryt').dataTable($.extend(true, {}, dataTablesDefaults, {
34             'sPaginationType': 'full_numbers',
35             [% IF compareinv2barcd %]
36                 // sort on callnumber
37                 "aaSorting": [[ 1, "asc" ]],
38             [% ELSE %]
39                 // first column contains checkboxes
40                 "aoColumnDefs": [
41                     { "bSortable": false, "bSearchable": false, "aTargets": [ 0 ] },
42                 ],
43                 // 3rd column is callnumber
44                 "aaSorting": [[ 2, "asc" ]],
45             [% END %]
46             'fnDrawCallback': function() {
47                 //bind the click handler script to the newly created elements held in the table
48                 $('.openWin').bind('click',function(e){
49                     e.preventDefault();
50                     openWindow(this.href,'marcview',800,600);
51                 });
52             }
53         } ));
54
55
56         $("#continuewithoutmarkingbutton").click(function(){
57             inventorydt.fnPageChange( 'next' );
58             return false;
59         });
60
61         $("#markseenandcontinuebutton").click(function(){
62             var param = '';
63             $("input:checked").each(function() {
64                 param += "|" + $(this).attr('name');
65             });
66             $.post('/cgi-bin/koha/tools/ajax-inventory.pl', { seen: param });
67             inventorydt.fnPageChange( 'next' );
68             return false;
69         });
70
71         $("#markseenandquit").click(function(){
72             var param = '';
73             $("input:checked").each(function() {
74                 param += "|" + $(this).attr('name');
75             });
76             $.ajax({
77               type: 'POST',
78               url: '/cgi-bin/koha/tools/ajax-inventory.pl',
79               data: { seen: param},
80               async: false
81             });
82             document.location.href = '/cgi-bin/koha/tools/inventory.pl';
83             return false;
84         });
85
86
87     $(".checkall").click(function(){
88             $(".checkboxed").checkCheckboxes();
89             return false;
90         });
91     $(".clearall").click(function(){
92             $(".checkboxed").unCheckCheckboxes();
93             return false;
94         });
95     $("#inventory_form").on("submit",function(){
96         return checkForm();
97     });
98
99     // #uploadbarcodes and #compareinv2barcd determine the behavior of
100     // the controls within the barcode fieldset and the optional filters
101     $("#uploadbarcodes").change(function() {
102         if( $("#uploadbarcodes").val() ) {
103             $("#setdate").prop('disabled',false);
104             $("#compareinv2barcd").prop('disabled',false);
105             $("#dont_checkin").prop('disabled',false);
106             if( $("#compareinv2barcd").attr('checked') ) {
107                 $("fieldset#optionalfilters").show();
108             } else {
109                 $("fieldset#optionalfilters").hide();
110             }
111         } else {
112             $("#setdate").prop('disabled',true);
113             $("#compareinv2barcd").prop('disabled',true);
114             $("#compareinv2barcd").attr('checked',false);
115             $("#dont_checkin").prop('disabled',true);
116             $("#dont_checkin").attr('checked',false);
117             $("fieldset#optionalfilters").show();
118         }
119     });
120     $("#compareinv2barcd").click(function() {
121         if( $("#compareinv2barcd").attr('checked') ) {
122             $("fieldset#optionalfilters").show();
123         } else {
124             $("fieldset#optionalfilters").hide();
125         }
126     });
127 });
128 //]]>
129 </script>
130 </head>
131 <body id="tools_inventory" class="tools">
132 [% INCLUDE 'header.inc' %]
133 [% INCLUDE 'cat-search.inc' %]
134
135 <div id="breadcrumbs"><a href="/cgi-bin/koha/mainpage.pl">Home</a> &rsaquo; <a href="/cgi-bin/koha/tools/tools-home.pl">Tools</a> &rsaquo; [% IF (loop) %]<a href="/cgi-bin/koha/tools/inventory.pl">Inventory</a> &rsaquo; Results[% ELSE %]Inventory[% END %]</div>
136
137 <div id="doc3" class="yui-t2">
138
139    <div id="bd">
140     <div id="yui-main">
141     <div class="yui-b">
142     <h1>Inventory</h1>
143     [% IF (moddatecount) %]<div class="dialog message">[% moddatecount %] items modified : datelastseen set to [% date | $KohaDates %]</div>
144     <div class="dialog alert">Number of potential barcodes read: [% LinesRead %]</div>[% END %]
145     [% IF (errorfile) %]<div class="dialog alert">[% errorfile %] can't be opened</div>[% END %]
146     [% IF (err_length && err_length==1) %]<div class="dialog alert">There was 1 barcode that was too long.</div>[% END %]
147     [% IF (err_length && err_length>1) %]<div class="dialog alert">There were [% err_length %] barcodes that were too long.</div>[% END %]
148     [% IF (err_data && err_data==1) %]<div class="dialog alert">There was 1 barcode that contained at least one unprintable character.</div>[% END %]
149     [% IF (err_data && err_data>1) %]<div class="dialog alert">There were [% err_data %] barcodes that contained at least one unprintable character.</div>[% END %]
150     [% FOREACH error IN errorloop %]
151         <div class="dialog alert">
152             [% error.barcode %]
153             [% IF (error.ERR_BARCODE) %]: barcode not found[% END %]
154             [% IF (error.ERR_WTHDRAWN) %]: item withdrawn[% END %]
155             [% IF (error.ERR_ONLOAN_RET) %]: item was on loan. It was returned before marked as seen[% END %]
156             [% IF (error.ERR_ONLOAN_NOT_RET) %]: item was on loan. couldn't be returned.[% END %]
157         </div>
158     [% END %]
159        [% UNLESS op %]
160     <div class="yui-g">
161     <form method="post" id="inventory_form" action="/cgi-bin/koha/tools/inventory.pl" enctype="multipart/form-data">
162         <fieldset class="rows">
163           <legend>Use a barcode file</legend>
164           <ol>
165             <li><label for="uploadbarcodes">Barcode file: </label> <input type="file" id="uploadbarcodes" name="uploadbarcodes" /></li>
166             <li><label for="setdate">Set inventory date to:</label> <input type="text" id="setdate" name="setdate" value="[% today | $KohaDates %]" class="datepicker" disabled /></li>
167             <li><label for="compareinv2barcd">Compare barcodes list to results: </label><input type="checkbox" name="compareinv2barcd" id="compareinv2barcd" disabled /></li>
168             <li><label for="dont_checkin">Do not check in items scanned during inventory: </label><input type="checkbox" name="dont_checkin" id="dont_checkin" disabled /></li>
169           </ol>
170         </fieldset>
171
172         <fieldset class="rows">
173         <legend>Item location filters</legend>
174         <ol><li>
175         <label for="branch">Library: </label>
176             <input type="radio" name="branch" value="homebranch"> Home library</input>
177             <input type="radio" name="branch" value="holdingbranch"> Current library</input>
178         </li><li>
179         <label for="branchloop">Library: </label><select id="branchloop" name="branchcode" style="width:12em;">
180             <option value="">All libraries</option>
181             [% PROCESS options_for_libraries libraries => Branches.all( selected => branchcode, unfiltered => 1, ) %]
182         </select>
183         </li>
184         [% IF (authorised_values) %]
185         <li>
186             <label for="locationloop">Shelving location (items.location) is: </label>
187         <select id="locationloop" name="location">
188                 <option value="">Filter location</option>
189         [% FOREACH value IN authorised_values %]
190             [% IF (value.selected) %]
191                 <option value="[% value.authorised_value %]" selected="selected">[% value.lib %]</option>
192             [% ELSE %]
193                 <option value="[% value.authorised_value %]">[% value.lib %]</option>
194             [% END %]
195         [% END %]
196         </select>        </li>
197         [% END %]
198         <li>
199             <label for="minlocation">Item callnumber between: </label>
200                 <input type="text" name="minlocation" id="minlocation" value="[% minlocation %]" /> (items.itemcallnumber)  </li>
201            <li><label for="maxlocation">...and: </label>
202                 <input type="text" name="maxlocation" id="maxlocation" value="[% maxlocation %]" />
203         </li>
204     </ol>
205     </fieldset>
206
207     <fieldset class="rows" id="optionalfilters">
208             <legend>Optional filters for inventory list or comparing barcodes</legend>
209             <br/>
210             <div id="statuses" style="display: block;">
211                   [% FOREACH status IN statuses %]
212                       [% IF (status.values) %]
213                           <fieldset style="float: left; padding: 5px; margin: 5px;text-align:right">
214                               <legend>[% status.fieldname %]</legend>
215                               <ul id="statuses-[% fieldname %]" style="display: inline;">
216                               [% FOREACH value IN status.values %]
217                                   [% IF (value.lib) %]
218                                     <li>
219                                     <label for="[% value.id %]">
220                                         [% IF value.authorised_value==0 %]
221                                             For loan
222                                         [% ELSE %]
223                                             [% value.lib %]
224                                         [% END %]
225                                     </label>
226                                     <input type="checkbox" name="status-[% status.fieldname %]-[% value.authorised_value %]" id="[% value.authorised_value %]" />
227                                     </li>
228                                   [% END %]
229                               [% END %]
230                               </ul>
231                           </fieldset>
232                       [% END %]
233                   [% END %]
234                 </div>
235         <ol>
236         <li>
237             <br/>
238             <label for="datelastseen">Last inventory date:</label>
239             <input type="text" id="datelastseen" name="datelastseen" value="[% datelastseen | $KohaDates %]" class="datepicker" />
240             (Skip records marked as seen on or after this date.)
241         </li>
242         <li>
243             <label for="ignoreissued">Skip items on loan: </label>
244             [% IF (ignoreissued) %]
245                 <input type="checkbox" id="ignoreissued" name="ignoreissued" checked="checked" />
246             [% ELSE %]
247                 <input type="checkbox" id="ignoreissued" name="ignoreissued" />
248             [% END %]
249         </li>
250         </ol>
251     </fieldset>
252
253         <fieldset class="rows">
254           <legend>Additional options</legend>
255           <ol>
256
257         <li>
258            <label for="CSVexport">Export to CSV file: </label>
259            <input type="checkbox" name="CSVexport" id="CSVexport" />
260         </li>
261         </ol>
262   </fieldset>
263             <input type="hidden" name="op" value="do_it" />
264
265             <fieldset class="action"><input type="submit" value="Submit" class="button" /></fieldset>
266     </form>
267     </div>
268     </div>
269     [% END %]
270     [% IF (op) %]
271     <form method="post" action="/cgi-bin/koha/tools/inventory.pl" class="checkboxed">
272     <input type="hidden" name="minlocation" value="[% minlocation %]" />
273     <input type="hidden" name="maxlocation" value="[% maxlocation %]" />
274     <input type="hidden" name="location" value="[% location %]" />
275     <input type="hidden" name="branchcode" value="[% branchcode %]" />
276     <input type="hidden" name="datelastseen" value="[% datelastseen %]" />
277
278     [% UNLESS uploadedbarcodesflag %]
279       <div><a href="#" class="checkall"><i class="fa fa-check"></i> Select all</a> <a href="#" class="clearall"><i class="fa fa-remove"></i> Clear all</a></div>
280     [% END %]
281
282     <table id="inventoryt">
283     <thead>
284         <tr>
285             [% UNLESS uploadedbarcodesflag %]<th>Seen</th>[% END %]
286             <th>Barcode</th>
287             <th>Call number</th>
288             <th>Library</th>
289             <th>Title</th>
290             <th>Status</th>
291             <th>Lost</th>
292             <th>Damaged</th>
293             <th>Withdrawn</th>
294             <th>Last seen</th>
295             <th>Problems</th>
296         </tr>
297     </thead>
298     <tbody>
299     [% FOREACH result IN loop %]
300         <tr>
301             [% UNLESS uploadedbarcodesflag %]
302               <td>
303                 <input type="checkbox" name="SEEN-[% result.itemnumber %]" value="1" />
304               </td>
305             [% END %]
306             <td>
307             [% result.barcode | html %]
308             </td>
309             <td>[% result.itemcallnumber | html %]</td>
310             <td>
311                 [% Branches.GetName( result.homebranch ) %]
312                 <span class="shelvingloc">[% result.location | html %]</span>
313             </td>
314             <td>
315                 <a href="/cgi-bin/koha/catalogue/MARCdetail.pl?biblionumber=[% result.biblionumber %]" class="openWin">[% result.title | html %]</a>
316                 [% IF ( result.author ) %]
317                     by <span class="author">[% result.author | html %]</span>
318                 [% END %]
319             </td>
320             <td>
321             [% result.notforloan | html %]
322             </td>
323             <td>
324             [% result.itemlost | html %]
325             </td>
326             <td>
327             [% result.damaged | html %]
328             </td>
329             <td>
330             [% result.withdrawn | html %]
331             </td>
332             <td>
333             [% result.datelastseen | $KohaDates | html %]
334             </td>
335             <td>
336             [% FOREACH problem IN result.problems %]
337                 [% IF problem.key == 'wrongplace' %]
338                     Found in wrong place<br/>
339                 [% ELSIF problem.key == 'changestatus' %]
340                     Unknown not-for-loan status<br/>
341                 [% ELSIF problem.key == 'not_scanned' %]
342                     Missing (not scanned)<br/>
343                 [% ELSIF problem.key == 'checkedout' %]
344                     Still checked out<br/>
345                 [% ELSIF problem.key == 'no_barcode' %]
346                     No barcode<br/>
347                 [% END %]
348             [% END %]
349             </td>
350         </tr>
351     [% END %]
352     </tbody>
353     </table>
354     <div class="spacer"></div>
355     [% UNLESS uploadedbarcodesflag %]
356       <div style="padding : .3em 0"><a href="#" class="checkall"><i class="fa fa-check"></i> Select all</a> <a href="#" class="clearall"><i class="fa fa-remove"></i> Clear all</a></div>
357       <input type="submit" id="markseenandquit" value="Mark seen and quit" />
358       <input type="submit" value="Mark seen and continue &gt;&gt;" id="markseenandcontinuebutton" />
359       <input type="submit" value="Continue without marking &gt;&gt;" id="continuewithoutmarkingbutton" class="submit" />
360     [% END %]
361     </form>
362
363     </div>
364
365     [% END %]
366 </div>
367 <div class="yui-b">
368 [% INCLUDE 'tools-menu.inc' %]
369 </div>
370 </div>
371 [% INCLUDE 'intranet-bottom.inc' %]