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