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