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