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