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