Bug 7180: (follow-up) restore ability to select bibs in middle of import batch
[koha-equinox.git] / koha-tmpl / intranet-tmpl / prog / en / modules / acqui / addorderiso2709.tt
1 [% USE KohaDates %]
2 [% INCLUDE 'doc-head-open.inc' %]
3 <title>Koha &rsaquo; Acquisitions &rsaquo; Order staged MARC records
4 [% IF ( batch_details ) %]
5  &rsaquo; Batch [% import_batch_id %]
6 [% ELSE %]
7  &rsaquo; Batch list
8 [% END %]
9 </title>
10 [% INCLUDE 'greybox.inc' %]
11 <link rel="stylesheet" type="text/css" href="[% themelang %]/css/datatables.css" />
12 [% INCLUDE 'doc-head-close.inc' %]
13 [% INCLUDE 'datatables.inc' %]
14 <script type="text/javascript" src="[% interface %]/lib/jquery/plugins/jquery.checkboxes.min.js"></script>
15 <script type="text/javascript" src="[% themelang %]/js/acq.js"></script>
16 <script type="text/JavaScript">
17 //<![CDATA[
18     $(document).ready(function() {
19         $("#files").dataTable($.extend(true, {}, dataTablesDefaults, {
20             "aoColumnDefs": [
21                 { "bSortable": false, "bSearchable": false, 'aTargets': [ 'NoSort' ] },
22                 { "sType": "anti-the", "aTargets" : [ "anti-the" ] },
23                 { "sType": "title-string", "aTargets" : [ "title-string" ] }
24             ],
25             "sPaginationType": "four_button",
26             "aaSorting": []
27         } ) );
28
29         $("select[name='all_budget_id'] .b_inactive").hide();
30         $("select[name='budget_id'] .b_inactive").hide();
31
32         $("#showallbudgets").click(function() {
33             if ($(this).is(":checked")) {
34                 $("select[name='budget_id'] .b_inactive").show();
35             }
36             else {
37                 $("select[name='budget_id'] .b_inactive").hide();
38             }
39         });
40
41         $("#all_showallbudgets").click(function() {
42             if ($(this).is(":checked")) {
43                 $("select[name='all_budget_id'] .b_inactive").show();
44             }
45             else {
46                 $("select[name='all_budget_id'] .b_inactive").hide();
47             }
48         });
49
50         $("select[name='budget_id']").change(function(){
51             var sort1_authcat = $(this).find("option:selected").attr('data-sort1-authcat');
52             var sort2_authcat = $(this).find("option:selected").attr('data-sort2-authcat');
53             var destination_sort1 = $(this).parents('fieldset').find('li.sort1').find('input[name="sort1"]');
54             var sort1 = $(destination_sort1).val() || "";
55             if ( destination_sort1.length < 1 ) {
56                 destination_sort1 = $(this).parents('fieldset').find('li.sort1 > select[name="sort1"]');
57             }
58             var destination_sort2 = $(this).parents('fieldset').find('li.sort2').find('input[name="sort2"]');
59             var sort2 = $(destination_sort2).val() || "";
60             if ( destination_sort2.length < 1 ) {
61                 destination_sort2 = $(this).parents('fieldset').find('li.sort2').find('select[name="sort2"]');
62             }
63             getAuthValueDropbox( 'sort1', sort1_authcat, destination_sort1, sort1 );
64
65             getAuthValueDropbox( 'sort2', sort2_authcat, destination_sort2, sort2 );
66         } );
67
68         $("select[name='budget_id']").change();
69
70         $("select[name='all_budget_id']").change(function(){
71             var sort1_authcat = $(this).find("option:selected").attr('data-sort1-authcat');
72             var sort2_authcat = $(this).find("option:selected").attr('data-sort2-authcat');
73             var destination_sort1 = $(this).parent().siblings('li').find('input[name="all_sort1"]');
74             if ( destination_sort1.length < 1 ) {
75                 destination_sort1 = $(this).parent().siblings('li').find('select[name="all_sort1"]');
76             }
77             var destination_sort2 = $(this).parent().siblings('li').find('input[name="all_sort2"]');
78             if ( destination_sort2.length < 1 ) {
79                 destination_sort2 = $(this).parent().siblings('li').find('select[name="all_sort2"]');
80             }
81             getAuthValueDropbox( 'sort1', sort1_authcat, destination_sort1 );
82             getAuthValueDropbox( 'sort2', sort2_authcat, destination_sort2 );
83             $(this).parent().siblings('li').find('select[name="sort1"]').attr('name', 'all_sort1');
84             $(this).parent().siblings('li').find('input[name="sort1"]').attr('name', 'all_sort1');
85             $(this).parent().siblings('li').find('select[name="sort2"]').attr('name', 'all_sort2');
86             $(this).parent().siblings('li').find('input[name="sort2"]').attr('name', 'all_sort2');
87         } );
88
89         $("select[name='all_budget_id']").change();
90
91         $("#records_to_import fieldset.rows ol").hide();
92         $('input:checkbox[name="import_record_id"]').change(function(){
93             var container = $(this).parents("fieldset");
94             if ( $(this).is(':checked') ) {
95                 $(container).addClass("selected");
96                 $(container).removeClass("unselected");
97                 $(container).find("ol").toggle(true);
98             } else {
99                 $(container).addClass("unselected");
100                 $(container).removeClass("selected");
101                 $(container).find("ol").toggle(false);
102             }
103         } );
104
105         $("input:checkbox").attr("checked", false);
106         $("div.biblio.unselected select").attr("disabled", false);
107         $("div.biblio.unselected input").attr("disabled", false);
108
109         $("#checkAll").click(function(){
110             $("#Aform").checkCheckboxes();
111             $("input:checkbox[name='import_record_id']").change();
112             return false;
113         });
114         $("#unCheckAll").click(function(){
115             $("#Aform").unCheckCheckboxes();
116             $("input:checkbox[name='import_record_id']").change();
117             return false;
118         });
119
120         $("#Aform").on("submit", function(){
121             if ( $("input:checkbox[name='import_record_id']:checked").length < 1 ) {
122                 alert(_("There is no record selected"));
123                 return false;
124             }
125
126             var error = 0;
127             $("input:checkbox[name='import_record_id']:checked").parents('fieldset').find('input[name="quantity"]').each(function(){
128                 if ( $(this).val().length < 1 || isNaN( $(this).val() ) ) {
129                     error++;
130                 }
131             });
132             if ( error > 0 ) {
133                 alert(error + " " + _("quantity values are not filled in or are not numbers"));
134                 return false;
135             }
136
137             return disableUnchecked($(this));
138         });
139         $('#tabs').tabs();
140     });
141
142     function disableUnchecked(form){
143         $("fieldset.biblio.unselected").each(function(){
144             $(this).remove();
145         });
146         return 1;
147     }
148 //]]>
149 </script>
150 </head>
151 <body id="acq_addorderiso2709" class="acq">
152 [% INCLUDE 'header.inc' %]
153 [% INCLUDE 'acquisitions-search.inc' %]
154 <div id="breadcrumbs"><a href="/cgi-bin/koha/mainpage.pl">Home</a> &rsaquo; <a href="/cgi-bin/koha/acqui/acqui-home.pl">Acquisitions</a> &rsaquo; <a href="/cgi-bin/koha/acqui/supplier.pl?booksellerid=[% booksellerid %]">[% booksellername %]</a> &rsaquo; <a href="/cgi-bin/koha/acqui/basket.pl?basketno=[% basketno %]">Basket [% basketno %]</a> &rsaquo;  Add orders from iso2709 file</div>
155 <div id="doc3" class="yui-t2">
156    <div id="bd">
157        <div id="yui-main">
158            <div class="yui-b">
159              [% IF ( batch_details ) %]
160                 <h1>Add orders from [% comments %]
161                     ([% file_name %] staged on [% upload_timestamp | $KohaDates with_hours => 1 %])
162                 </h1>
163                 <form action="/cgi-bin/koha/acqui/addorderiso2709.pl" method="post" id="Aform">
164                 <div id="tabs" class="toptabs">
165                   <ul>
166                     <li><a href="#records_to_import">Select to import</a></li>
167                     <li><a href="#items_info" class="items_info">Item information</a></li>
168                     <li><a href="#accounting_details">Default accounting details</a></li>
169                   </ul>
170
171                   <div id="records_to_import">
172                     <span class="checkall"><a id="checkAll" href="#">Check all</a></span>
173                     <span class="uncheckall"><a id="unCheckAll" href="#">Uncheck all</a></span>
174                     <label for="showallbudgets" style="float:none;width:auto;">&nbsp;Show all funds:</label>
175                     <input type="checkbox" id="showallbudgets" />
176                         <input type="hidden" name="op" value="import_records"/>
177                         <input type="hidden" name="basketno" value="[% basketno %]" />
178                         <input type="hidden" name="booksellerid" value="[% booksellerid %]" />
179                         <input type="hidden" name="import_batch_id" value="[%import_batch_id %]" />
180                         <input type="hidden" name="ordernumber" value="[% ordernumber %]" />
181
182                         [% FOREACH cur IN loop_currencies %]
183                             <input type="hidden" name="[% cur.currency %]" value="[% cur.rate %]" />
184                         [% END %]
185
186                         [% FOREACH biblio IN biblio_list %]
187                         <fieldset class="biblio unselected rows" style="float:none;">
188                           <legend>
189                             <label for="record_[% biblio.import_record_id %]" style="width:auto;">
190                               <input type="checkbox" name="import_record_id" id="record_[% biblio.import_record_id %]" value="[% biblio.import_record_id %]" />
191                               <span class="citation">[% biblio.citation %]</span>
192                             </label>
193                             <span class="links" style="font-weight: normal;">
194                               ( <a href="/cgi-bin/koha/catalogue/showmarc.pl?importid=[% biblio.import_record_id %]" title="MARC" rel="gb_page_center[600,500]">MARC</a> | <a href="/cgi-bin/koha/catalogue/showmarc.pl?viewas=card&amp;importid=[% biblio.import_record_id %]" title="Card" rel="gb_page_center[600,500]">Card</a> | <a href="/cgi-bin/koha/acqui/neworderempty.pl?booksellerid=[% booksellerid %]&amp;basketno=[% basketno %]&amp;breedingid=[% biblio.import_record_id %]&amp;import_batch_id=[% biblio.import_batch_id %]&amp;biblionumber=[% biblio.match_biblionumber %]">Add order</a> )
195                             </span>
196                           </legend>
197                           <ol>
198                             <li class="status">
199                               <span class="match">
200                                 [% IF ( biblio_lis.overlay_status == 'no_match' ) %]
201                                     No match
202                                 [% ELSIF ( biblio_lis.overlay_status == 'match_applied' ) %]
203                                     Match applied
204                                 [% ELSIF ( biblio_lis.overlay_status == 'auto_match' ) %]
205                                     Match found
206                                 [% ELSE %]
207                                     [% biblio_lis.overlay_status %]
208                                 [% END %]
209                                 [% IF ( biblio.match_biblionumber ) %]
210                                   Matches biblio [% biblio.match_biblionumber %] (score = [% biblio.match_score %]): <a href="/cgi-bin/koha/catalogue/detail.pl?biblionumber=[% biblio.match_biblionumber %]">[% biblio.match_citation %]</a>
211                                 [% END %]
212                               </span>
213                             </li>
214                             <li class="quantity">
215                                 <label for="quantity_record_[% biblio.import_record_id %]" class="required">Quantity: </label>
216                                 <input id="quantity_record_[% biblio.import_record_id %]" type="text" value="[% biblio.quantity.length ? biblio.quantity : 1 %]" name="quantity" />
217                             </li>
218                             <li class="price">
219                                 <label for="price_record_[% biblio.import_record_id %]">Price: </label>
220                                 <input id="price_record_[% biblio.import_record_id %]" type="text" value="[% biblio.price %]" name="price" />
221                             </li>
222                             <li class="discount">
223                                 <label for="discount_record_[% biblio.import_record_id %]">Discount: </label>
224                                 <input id="discount_record_[% biblio.import_record_id %]" type="text" value="[% biblio.discount %]" name="discount" size="6" /> %
225                                 (If empty, discount rate from vendor will be used)
226                             </li>
227                             <li class="budget">
228                                 <label for="fund_record_[% biblio.import_record_id %]">Fund: </label>
229                                 [% IF ( close ) %]
230                                   <input type="hidden" size="20" name="budget_id" value="[% budget_id %]" />[% Budget_name %]
231                                 [% ELSE %]
232                                   <select id="fund_record_[% biblio.import_record_id %]" size="1" name="budget_id">
233                                     <option value="">Select a fund</option>
234                                     [% FOREACH budget IN budget_loop %]
235                                         [% IF ( budget.b_id == biblio.budget_id ) %]
236                                           [% IF budget.b_active %]
237                                             <option value="[% budget.b_id %]" data-sort1-authcat="[% budget.b_sort1_authcat %]" data-sort2-authcat="[% budget.b_sort2_authcat %]" selected="selected">[% budget.b_txt %]</option>
238                                           [% ELSE %]
239                                             <option value="[% budget.b_id %]" data-sort1-authcat="[% budget.b_sort1_authcat %]" data-sort2-authcat="[% budget.b_sort2_authcat %]" selected="selected">[% budget.b_txt %] (inactive)</option>
240                                           [% END %]
241                                         [% ELSE %]
242                                             [% IF budget.b_active %]<option value="[% budget.b_id %]" data-sort1-authcat="[% budget.b_sort1_authcat %]" data-sort2-authcat="[% budget.b_sort2_authcat %]">[% budget.b_txt %]</option>
243                                             [% ELSE %]<option value="[% budget.b_id %]" class="b_inactive" data-sort1-authcat="[% budget.b_sort1_authcat %]" data-sort2-authcat="[% budget.b_sort2_authcat %]">[% budget.b_txt %] (inactive)</option>
244                                             [% END %]
245                                         [% END %]
246                                     [% END %]
247                                   </select>
248                                 [% END %]
249                             </li>
250                             <li class="sort1">
251                                 <label for="sort1_record_[% biblio.import_record_id %]">Statistic 1: </label>
252                                 <input id="sort1_record_[% biblio.import_record_id %]" type="text" id="sort1" size="20" name="sort1" value="[% biblio.sort1 %]" />
253                             </li>
254                             <li class="sort2">
255                                 <label for="sort2_record_[% biblio.import_record_id %]">Statistic 2: </label>
256                                 <input id="sort2_record_[% biblio.import_record_id %]" type="text" id="sort2" size="20" name="sort2" value="[% biblio.sort2 %]" />
257                             </li>
258                           </ol>
259                         </fieldset>
260                         [% END %]
261                       </div>
262                       <div id="items_info">
263                         <h2>Item information</h2>
264                         <p>Import all the checked items in the basket with the following parameters:</p>
265
266                         [% IF ( items ) %]
267                         <fieldset class="rows" style="float:none;">
268                             <legend>Item</legend>
269                             [% IF ( NoACQframework ) %]
270                                 <div class="dialog message">No ACQ framework, using default. You should create a framework with code ACQ, the items framework would be used</div>
271                             [% END %]
272                             [% FOREACH item IN items %]
273                             <div id="outeritemblock">
274                             <div id="itemblock">
275                                 <ol>
276                                 [% FOREACH iteminformatio IN item.iteminformation %]<li style="[% iteminformatio.hidden %];">
277                                     <div class="subfield_line" id="subfield[% iteminformatio.serialid %][% iteminformatio.countitems %][% iteminformatio.subfield %][% iteminformatio.random %]">
278                                         [% IF (iteminformatio.mandatory) %]
279                                             <label class="required">[% iteminformatio.subfield %] - [% iteminformatio.marc_lib %]</label>
280                                         [% ELSE %]
281                                             <label>[% iteminformatio.subfield %] - [% iteminformatio.marc_lib %]</label>
282                                         [% END %]
283
284                                         [% iteminformatio.marc_value %]
285                                         <input type="hidden" name="itemid" value="1" />
286                                         <input type="hidden" name="kohafield" value="[% iteminformatio.kohafield %]" />
287                                         <input type="hidden" name="tag" value="[% iteminformatio.tag %]" />
288                                         <input type="hidden" name="subfield" value="[% iteminformatio.subfield %]" />
289                                         <input type="hidden" name="mandatory" value="[% iteminformatio.mandatory %]" />
290                                         [% IF ( iteminformatio.mandatory ) %] <span class="required">Required</span>[% END %]
291                                     </div></li>
292                                 [% END %]
293                                 </ol>
294                             </div><!-- /iteminformation -->
295                             </div>
296                             [% END %] <!-- /items -->
297                         </fieldset>
298                         [% END %] <!-- items -->
299                       </div>
300                       <div id="accounting_details">
301                         <p>Import all the checked items in the basket with the following accounting details (used only if no information is filled for the item):</p>
302                         <fieldset class="rows" style="float:none;">
303                             <legend>Accounting details</legend>
304                             <ol>
305                                 <li>
306                                     <!-- origquantityrec only here for javascript compatibility (additem.js needs it, useless here, usefull when receiveing an order -->
307                                     <input id="origquantityrec" readonly="readonly" type="hidden" name="origquantityrec" value="1" />
308                                 </li>
309                                 <li>
310                                     [% IF ( close ) %]
311                                         <span class="label">Fund: </span>
312                                         <input type="hidden" size="20" name="budget_id" id="budget_id" value="[% budget_id %]" />[% Budget_name %]
313                                     [% ELSE %]
314                                         <li>
315                                             <label for="all_currency">Currency:</label>
316                                             <select name="all_currency" id="all_currency">
317                                             [% FOREACH loop_currencie IN loop_currencies %]
318                                                 [% IF ( loop_currencie.selected ) %]
319                                                     <option value="[% loop_currencie.currcode %]" selected="selected">[% loop_currencie.currcode %]</option>
320                                                 [% ELSE %]
321                                                     <option value="[% loop_currencie.currcode %]">[% loop_currencie.currcode %]</option>
322                                                 [% END %]
323                                             [% END %]
324                                             </select>
325                                         </li>
326                                         <li>
327                                             <label for="all_budget_id">Fund: </label>
328                                             <select id="all_budget_id" size="1" name="all_budget_id">
329                                               <option value="">Select a fund</option>
330                                             [% FOREACH budget_loo IN budget_loop %]
331                                                 [% IF ( budget_loo.b_active ) %]<option value="[% budget_loo.b_id %]" data-sort1-authcat="[% budget_loo.b_sort1_authcat %]" data-sort2-authcat="[% budget_loo.b_sort2_authcat %]">[% budget_loo.b_txt %]</option>
332                                                 [% ELSE %]<option value="[% budget_loo.b_id %]" class="b_inactive" data-sort1-authcat="[% budget_loo.b_sort1_authcat %]" data-sort2-authcat="[% budget_loo.b_sort2_authcat %]">[% budget_loo.b_txt %] (inactive)</option>
333                                                 [% END %]
334                                             [% END %]
335                                             </select>
336                                             <label for="all_showallbudgets" style="float:none;width:auto;">&nbsp;Show all:</label>
337                                             <input type="checkbox" id="all_showallbudgets" />
338                                         </li>
339                                     [% END %]
340                                 </li>
341                                 <li>
342                                     <label for="all_order_internalnote">Internal note: </label>
343                                     <textarea id="all_order_internalnote" cols="30" rows="3" name="all_order_internalnote"></textarea>
344                                 </li>
345                                 <li>
346                                     <label for="all_order_vendornote">Vendor note: </label>
347                                     <textarea id="all_order_vendornote" cols="30" rows="3" name="all_order_vendornote"></textarea>
348                                 </li>
349                                 <li>
350                                     <div class="hint">The 2 following fields are available for your own usage. They can be useful for statistical purposes</div>
351                                     <label for="all_sort1">Statistic 1: </label>
352                                     <input type="text" id="all_sort1" size="20" name="all_sort1" value="" />
353                                 </li>
354                                 <li>
355                                     <label for="all_sort2">Statistic 2: </label>
356                                     <input type="text" id="all_sort2" size="20" name="all_sort2" value="" />
357                                 </li>
358                             </ol>
359                         </fieldset>
360                       </div>
361                       </div>
362
363                       <fieldset class="action">
364                           <input type="submit" value="Save" /><a class="cancel" href="/cgi-bin/koha/acqui/basket.pl?basketno=[% basketno %]">Cancel</a>
365                       </fieldset>
366                     </form>
367                 [% ELSE %]
368                 <div>
369                   <h1>Choose the file to add to the basket</h1>
370                   <table id="files">
371                     <thead>
372                       <tr>
373                         <th>File name</th>
374                         <th>Comments</th>
375                         <th>Status</th>
376                         <th class="title-string">Staged</th>
377                         <th># Bibs</th>
378                         <th class="NoSort">&nbsp;</th>
379                       </tr>
380                     </thead>
381                     <tbody>
382                       [% FOREACH batch_lis IN batch_list %]
383                       <tr>
384                         <td>[% batch_lis.file_name %]</td>
385                         <td>[% batch_lis.comments %]</td>
386                         <td>
387                           [% IF ( batch_lis.import_status == 'cleaned' ) %]
388                             Cleaned
389                           [% ELSIF ( batch_lis.import_status == 'imported' ) %]
390                             Imported
391                           [% ELSIF ( batch_lis.import_status == 'importing' ) %]
392                             Importing
393                           [% ELSIF ( batch_lis.import_status == 'reverted' ) %]
394                             Reverted
395                           [% ELSIF ( batch_lis.import_status == 'reverting' ) %]
396                             Reverting
397                           [% ELSIF ( batch_lis.import_status == 'staged' ) %]
398                             Staged
399                           [% ELSE %]
400                             [% batch_lis.import_status %]
401                           [% END %]
402                         </td>
403                         <td><span title="[% batch_lis.staged_date %]">[% batch_lis.staged_date | $KohaDates with_hours => 1 %]</span></td>
404                         <td>[% batch_lis.num_biblios %]</td>
405                         <td><a href="[% batch_lis.scriptname %]?import_batch_id=[% batch_lis.import_batch_id %]&amp;basketno=[% basketno %]&amp;booksellerid=[% booksellerid %]">Add orders</a></td>
406                       </tr>
407                       [% END %]
408                     </tbody>
409                   </table>
410                 </div>
411                 [% END %]
412            </div>
413        </div>
414    </div>
415 </div>
416 </body>
417 </html>