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