946ead13025946b89cac0c640ea49af66cdacbca
[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     </ol>
87     </fieldset>
88
89     <fieldset class="rows" id="optionalfilters">
90             <legend>Optional filters for inventory list or comparing barcodes</legend>
91             <br/>
92             <div id="statuses" style="display: block;">
93                   [% FOREACH status IN statuses %]
94                       [% IF (status.values) %]
95                           <fieldset style="float: left; padding: 5px; margin: 5px;text-align:right">
96                               <legend>[% status.fieldname | html %]</legend>
97                               <ul id="statuses-[% fieldname | html %]" style="display: inline;">
98                               [% FOREACH value IN status.values %]
99                                   [% IF (value.lib) %]
100                                     <li>
101                                     <label for="[% value.id | html %]">
102                                         [% IF ( status.fieldname == 'items.notforloan' && value.authorised_value == 0 && value.lib == '__IGNORE__' ) %]
103                                             For loan
104                                         [% ELSE %]
105                                             [% value.lib | html %]
106                                         [% END %]
107                                     </label>
108                                     <input type="checkbox" name="status-[% status.fieldname | html %]-[% value.authorised_value | html %]" id="[% value.authorised_value | html %]" />
109                                     </li>
110                                   [% END %]
111                               [% END %]
112                               </ul>
113                           </fieldset>
114                       [% END %]
115                   [% END %]
116                 </div>
117         <ol>
118         <li>
119             <br/>
120             <label for="datelastseen">Last inventory date:</label>
121             <input type="text" id="datelastseen" name="datelastseen" value="[% datelastseen | $KohaDates %]" class="datepicker" />
122             (Skip records marked as seen on or after this date.)
123         </li>
124         <li>
125             <label for="ignoreissued">Skip items on loan: </label>
126             [% IF (ignoreissued) %]
127                 <input type="checkbox" id="ignoreissued" name="ignoreissued" checked="checked" />
128             [% ELSE %]
129                 <input type="checkbox" id="ignoreissued" name="ignoreissued" />
130             [% END %]
131         </li>
132         <li>
133             <label for="ignore_waiting_holds">Skip items on hold awaiting pickup: </label>
134             <input type="checkbox" id="ignore_waiting_holds" name="ignore_waiting_holds" />
135         </li>
136         </ol>
137     </fieldset>
138
139         <fieldset class="rows">
140           <legend>Additional options</legend>
141           <ol>
142
143         <li>
144            <label for="CSVexport">Export to CSV file: </label>
145            <input type="checkbox" name="CSVexport" id="CSVexport" />
146         </li>
147         </ol>
148   </fieldset>
149             <input type="hidden" name="op" value="do_it" />
150
151             <fieldset class="action"><input type="submit" value="Submit" class="button" /></fieldset>
152     </form>
153
154     [% END %]
155     [% IF (op) %]
156     <form method="post" action="/cgi-bin/koha/tools/inventory.pl" class="checkboxed">
157     <input type="hidden" name="minlocation" value="[% minlocation | html %]" />
158     <input type="hidden" name="maxlocation" value="[% maxlocation | html %]" />
159     <input type="hidden" name="location" value="[% location | html %]" />
160     <input type="hidden" name="branchcode" value="[% branchcode | html %]" />
161     <input type="hidden" name="datelastseen" value="[% datelastseen | html %]" />
162
163     [% UNLESS uploadedbarcodesflag %]
164       <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>
165     [% END %]
166
167     <table id="inventoryt">
168     <thead>
169         <tr>
170             [% UNLESS uploadedbarcodesflag %]<th>Seen</th>[% END %]
171             <th>Barcode</th>
172             <th>Call number</th>
173             <th>Library</th>
174             <th>Title</th>
175             <th>Not for loan</th>
176             <th>Lost</th>
177             <th>Damaged</th>
178             <th>Withdrawn</th>
179             <th>Last seen</th>
180             <th>Problems</th>
181         </tr>
182     </thead>
183     <tbody>
184     [% FOREACH result IN loop %]
185         <tr>
186             [% UNLESS uploadedbarcodesflag %]
187               <td>
188                 <input type="checkbox" name="SEEN-[% result.itemnumber | html %]" value="1" />
189               </td>
190             [% END %]
191             <td>
192             [% result.barcode | html %]
193             </td>
194             <td>[% result.itemcallnumber | html %]</td>
195             <td>
196                 [% Branches.GetName( result.homebranch ) | html %]
197                 <span class="shelvingloc">[% result.location | html %]</span>
198             </td>
199             <td>
200                 <a href="/cgi-bin/koha/catalogue/detail.pl?biblionumber=[% result.biblionumber | uri %]" class="openWin">[% result.title | html %]</a>
201                 [% IF ( result.author ) %]
202                     by <span class="author">[% result.author | html %]</span>
203                 [% END %]
204             </td>
205             <td>
206             [% result.notforloan | html %]
207             </td>
208             <td>
209             [% result.itemlost | html %]
210             </td>
211             <td>
212             [% result.damaged | html %]
213             </td>
214             <td>
215             [% result.withdrawn | html %]
216             </td>
217             <td>
218             [% result.datelastseen | $KohaDates %]
219             </td>
220             <td>
221             [% FOREACH problem IN result.problems %]
222                 [% IF problem.key == 'wrongplace' %]
223                     Found in wrong place<br/>
224                 [% ELSIF problem.key == 'changestatus' %]
225                     Unknown not-for-loan status<br/>
226                 [% ELSIF problem.key == 'not_scanned' %]
227                     Missing (not scanned)<br/>
228                 [% ELSIF problem.key == 'checkedout' %]
229                     Still checked out<br/>
230                 [% ELSIF problem.key == 'no_barcode' %]
231                     No barcode<br/>
232                 [% ELSIF problem.key == 'out_of_order' %]
233                     Item may be shelved out of order<br/>
234                 [% END %]
235             [% END %]
236             </td>
237         </tr>
238     [% END %]
239     </tbody>
240     </table>
241     <div class="spacer"></div>
242     [% UNLESS uploadedbarcodesflag %]
243       <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>
244       <input type="submit" id="markseenandquit" value="Mark seen and quit" />
245       <input type="submit" value="Mark seen and continue &gt;&gt;" id="markseenandcontinuebutton" />
246       <input type="submit" value="Continue without marking &gt;&gt;" id="continuewithoutmarkingbutton" class="submit" />
247     [% END %]
248     </form>
249
250
251     [% END %]
252
253             </main>
254         </div> <!-- /.col-sm-10.col-sm-push-2 -->
255
256         <div class="col-sm-2 col-sm-pull-10">
257             <aside>
258                 [% INCLUDE 'tools-menu.inc' %]
259             </aside>
260         </div> <!-- .col-sm-2.col-sm-pull-10 -->
261      </div> <!-- /.row -->
262
263 [% MACRO jsinclude BLOCK %]
264     [% Asset.js("js/tools-menu.js") | $raw %]
265     [% INCLUDE 'datatables.inc' %]
266     [% INCLUDE 'calendar.inc' %]
267     [% Asset.js("lib/jquery/plugins/jquery.checkboxes.min.js") | $raw %]
268     <script type="text/javascript">
269         function checkForm() {
270             if ( $('#uploadbarcodes').val() ) {
271                 if ( !(
272                     $('#branchloop').val()   ||
273                     $('#locationloop').val() ||
274                     $('#minlocation').val()  ||
275                     $('#maxlocation').val()  ||
276                     $('#statuses input:checked').length
277                 ) ) {
278                     return confirm(
279                         _("You have not selected any catalog filters and are about to compare a file of barcodes to your entire catalog.") + "\n\n" +
280                         _("For large catalogs this can result in unexpected behavior") + "\n\n" +
281                         _("Are you sure you want to do this?")
282                     );
283                 }
284             }
285
286             return true;
287         }
288
289         $(document).ready(function(){
290             inventorydt = $('#inventoryt').dataTable($.extend(true, {}, dataTablesDefaults, {
291                 'sPaginationType': 'full_numbers',
292                 [% IF compareinv2barcd %]
293                     // sort on callnumber
294                     "aaSorting": [[ 1, "asc" ]],
295                 [% ELSE %]
296                     // first column contains checkboxes
297                     "aoColumnDefs": [
298                         { "bSortable": false, "bSearchable": false, "aTargets": [ 0 ] },
299                     ],
300                     // 3rd column is callnumber
301                     "aaSorting": [[ 2, "asc" ]],
302                 [% END %]
303                 'fnDrawCallback': function() {
304                     //bind the click handler script to the newly created elements held in the table
305                     $('.openWin').bind('click',function(e){
306                         e.preventDefault();
307                         openWindow(this.href,'marcview',800,600);
308                     });
309                 }
310             } ));
311
312
313             $("#continuewithoutmarkingbutton").click(function(){
314                 inventorydt.fnPageChange( 'next' );
315                 return false;
316             });
317
318             $("#markseenandcontinuebutton").click(function(){
319                 var param = '';
320                 $("input:checked").each(function() {
321                     param += "|" + $(this).attr('name');
322                 });
323                 $.post('/cgi-bin/koha/tools/ajax-inventory.pl', { seen: param });
324                 inventorydt.fnPageChange( 'next' );
325                 return false;
326             });
327
328             $("#markseenandquit").click(function(){
329                 var param = '';
330                 $("input:checked").each(function() {
331                     param += "|" + $(this).attr('name');
332                 });
333                 $.ajax({
334                   type: 'POST',
335                   url: '/cgi-bin/koha/tools/ajax-inventory.pl',
336                   data: { seen: param},
337                   async: false
338                 });
339                 document.location.href = '/cgi-bin/koha/tools/inventory.pl';
340                 return false;
341             });
342
343
344             $(".checkall").click(function(){
345                     $(".checkboxed").checkCheckboxes();
346                     return false;
347                 });
348             $(".clearall").click(function(){
349                     $(".checkboxed").unCheckCheckboxes();
350                     return false;
351                 });
352             $("#inventory_form").on("submit",function(){
353                 return checkForm();
354             });
355
356             // #uploadbarcodes and #compareinv2barcd determine the behavior of
357             // the controls within the barcode fieldset and the optional filters
358             $("#uploadbarcodes").change(function() {
359                 if( $("#uploadbarcodes").val() ) {
360                     $("#setdate").prop('disabled',false);
361                     $("#compareinv2barcd").prop('disabled',false);
362                     $("#compareinv2barcd").attr('checked',true); // default
363                     $("#dont_checkin").prop('disabled',false);
364                     $("#out_of_order").prop('disabled',false);
365                     if( $("#compareinv2barcd").attr('checked') ) {
366                         $("fieldset#optionalfilters").show();
367                         $("#ignoreissued").attr('checked',true); // default
368                     } else {
369                         $("fieldset#optionalfilters").hide();
370                         $("#ignoreissued").attr('checked',false);
371                     }
372                 } else {
373                     $("#setdate").prop('disabled',true);
374                     $("#compareinv2barcd").prop('disabled',true);
375                     $("#compareinv2barcd").attr('checked',false);
376                     $("#dont_checkin").prop('disabled',true);
377                     $("#dont_checkin").attr('checked',false);
378                     $("#out_of_order").prop('disabled',true);
379                     $("#out_of_order").attr('checked',false);
380                     $("fieldset#optionalfilters").show();
381                 }
382             });
383             $("#compareinv2barcd").click(function() {
384                 if( $("#compareinv2barcd").attr('checked') ) {
385                     $("fieldset#optionalfilters").show();
386                     $("#ignoreissued").attr('checked',true); // default
387                 } else {
388                     $("#ignoreissued").attr('checked',false);
389                     $("fieldset#optionalfilters").hide();
390                 }
391             });
392         });
393     </script>
394 [% END %]
395
396 [% INCLUDE 'intranet-bottom.inc' %]