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