Bug 33005: (follow-up) Add spans for translatability
[koha.git] / koha-tmpl / intranet-tmpl / prog / en / modules / acqui / orderreceive.tt
1 [% USE raw %]
2 [% USE Asset %]
3 [% USE Koha %]
4 [% USE KohaDates %]
5 [% USE Branches %]
6 [% USE AuthorisedValues %]
7 [% USE ItemTypes %]
8 [% USE Price %]
9 [% SET footerjs = 1 %]
10 [% INCLUDE 'doc-head-open.inc' %]
11 <title>Receipt summary for : [% name | html %] [% IF ( invoice ) %]invoice, [% invoice | html %][% END %] &rsaquo; Acquisitions &rsaquo; Koha</title>
12 [% INCLUDE 'doc-head-close.inc' %]
13 </head>
14
15 <body id="acq_orderreceive" class="acq">
16 [% WRAPPER 'header.inc' %]
17     [% INCLUDE 'acquisitions-search.inc' %]
18 [% END %]
19
20 [% WRAPPER 'sub-header.inc' %]
21     [% WRAPPER breadcrumbs %]
22         [% WRAPPER breadcrumb_item %]
23             <a href="/cgi-bin/koha/acqui/acqui-home.pl">Acquisitions</a>
24         [% END %]
25         [% WRAPPER breadcrumb_item %]
26             <a href="/cgi-bin/koha/acqui/supplier.pl?booksellerid=[% order.basket.booksellerid | uri %]">[% name | html %]</a>
27         [% END %]
28         [% WRAPPER breadcrumb_item bc_active= 1 %]
29             [% IF ( invoice ) %]
30                 <span>Receive items from: [% name | html %] [[% invoice | html %]] (order #[% order.ordernumber | html %])</span>
31             [% ELSE %]
32                 <span>Receive items from: [% name | html %] (order #[% order.ordernumber | html %])</span>
33             [% END %]
34         [% END %]
35     [% END #/ WRAPPER breadcrumbs %]
36 [% END #/ WRAPPER sub-header.inc %]
37
38 <div class="main container-fluid">
39     <div class="row">
40     [% AcqCreateItem = order.basket.effective_create_items %]
41         <div class="col-sm-10 col-sm-push-2">
42             <main>
43
44 <h1>Receive items from : [% name | html %] [% IF ( invoice ) %][[% invoice | html %]] [% END %] (order #[% order.ordernumber | html %])</h1>
45
46 [% IF ( order ) %]
47     <form id="f" action="/cgi-bin/koha/acqui/finishreceive.pl" class="noEnterSubmit" method="post" onsubmit="return Check(this);">
48 <div class="row">
49 <div class="col-sm-6">
50     <div class="dialog alert order_error" style="display:none"></div>
51
52     <fieldset class="rows">
53     <legend>Catalog details</legend>
54     <ol>
55         <li>
56             <span class="label">Title: </span>
57             [% INCLUDE 'biblio-title.inc' biblio=order.biblio link = 1 %]
58         </li>
59     <li> <span class="label">Author: </span>
60         [% order.biblio.author | html %]</li>
61     <li><span class="label">Copyright: </span>
62         [% order.biblio.copyrightdate | html %]</li>
63     <li> <span class="label">ISBN: </span>
64         [% order.biblio.biblioitem.isbn | html %]</li>
65     <li> <span class="label">Series: </span>
66         [% order.biblio.seriestitle | html %]</li>
67     </ol>
68         </fieldset>
69
70     [% IF suggestion %]
71         <fieldset class="rows">
72         <legend>Suggestion</legend>
73         <ol>
74           <li>
75             <span class="label">Suggested by: </span>
76             [% suggestion.surnamesuggestedby | html %][% IF suggestion.firstnamesuggestedby %], [% suggestion.firstnamesuggestedby | html %][% END %] (<a href="/cgi-bin/koha/suggestion/suggestion.pl?suggestionid=[% suggestion.suggestionid | uri %]&amp;op=show">suggestion #[% suggestion.suggestionid | html %]</a>)
77             [% IF suggestion.reason %]
78                 <li>
79                     <span class="label">Reason:</span>
80                     [% SET suggestion_reasons = AuthorisedValues.GetAuthValueDropbox( 'SUGGEST' ) %]
81                     [% SET other_reason = 1 %]
82                     <select class="select-reason" id="reason" name="reason">
83                         <option value=""> -- Choose a reason -- </option>
84                         [% FOREACH reason IN suggestion_reasons %]
85                             [% IF reason.lib == suggestion.reason %]
86                                 <option value="[% reason.lib | html %]" selected="selected">[% reason.lib | html %]</option>
87                                 [% SET other_reason = 0 %]
88                             [% ELSE %]
89                                 <option value="[% reason.lib | html %]">[% reason.lib | html %]</option>
90                             [% END %]
91                         [% END %]
92                         <option value="other">Others...</option>
93                     </select>
94
95                     <span id="other_reason" name="other_reason">
96                         [% IF other_reason %]
97                             <input type="text" size="31" id="select-other_reason" name="other_reason" placeholder="please note your reason here..." value="[% suggestion.reason | html %]"/>
98                         [% ELSE %]
99                             <input type="text" size="31" id="select-other_reason" name="other_reason" placeholder="please note your reason here..." />
100                         [% END %]
101                         <a href="#back">Cancel</a>
102                     </span>
103
104                     <input type="hidden" name="suggestionid" value="[% suggestion.suggestionid | html %]" />
105                 </li>
106             [% END %]
107           </li>
108         </ol>
109         </fieldset>
110     [% END %]
111
112     [% IF order.subscriptionid and orders.count %]
113         <fieldset class="rows">
114             <legend>Receipt history for this subscription</legend>
115             <table id="orders">
116                 <thead>
117                     <tr>
118                         <th>Invoice</th>
119                         <th>Order number</th>
120                         <th>Creation date</th>
121                         <th>Receive date</th>
122                         <th>Quantity received</th>
123                         <th>Status</th>
124                         <th title="Actual cost tax exc. / Actual cost tax inc.">Spent</th>
125                         <th>Internal note</th>
126                     </tr>
127                 </thead>
128                 <tbody>
129                 [% FOR suborder IN orders %]
130                     <tr>
131                         <td>
132                         [% IF suborder.invoice %]
133                             [% IF CAN_user_acquisition %]
134                                 <a href="/cgi-bin/koha/acqui/invoice.pl?invoiceid=[% suborder.invoiceid | uri %]" title="Invoice detail page">
135                                    [% suborder.invoice.invoicenumber | html %]</a>
136                             [% ELSE %]
137                                 [% suborder.invoice.invoicenumber | html %]
138                             [% END %]
139                         [% END %]
140                         </td>
141                         <td>[% suborder.ordernumber | html %]</td>
142                         <td data-order="[% suborder.basket.creationdate | uri %]">[% suborder.basket.creationdate | $KohaDates%]</td>
143                         <td data-order="[% suborder.datereceived | uri %]">
144                             [% IF suborder.datereceived %]
145                                 [% suborder.datereceived | $KohaDates %]
146                             [% END %]
147                         </td>
148                         <td>[% suborder.quantityreceived | html %]</td>
149                         [% SWITCH suborder.orderstatus %]
150                             [%# FIXME We should only see/display Complete here, right? %]
151                             [% CASE 'new' %]
152                                 <td data-order="status_1">
153                                     <span>New</span>
154                             [% CASE 'ordered' %]
155                                 <td data-order="status_2">
156                                     <span>Ordered</span>
157                             [% CASE 'partial' %]
158                                 <td data-order="status_3">
159                                     <span>Partial</span>
160                             [% CASE 'complete' %]
161                                 <td data-order="status_4">
162                                     <span>Complete</span>
163                             [% CASE 'cancelled' %]
164                                 <td data-order="status_5">
165                                     <span>Cancelled</span>
166                           [% END %]
167                         </td>
168                         <td>
169                             [% IF suborder.datereceived %][%# FIXME Should only be true, right? %]
170                                 [%# FIXME What if unitprice has not been filled? %]
171                                 [% suborder.unitprice_tax_excluded * suborder.quantity | $Price %] / [% suborder.unitprice_tax_included * suborder.quantity | $Price %]
172                             [% END %]
173                         </td>
174                         <td>[% suborder.order_internalnote | html %]</td>
175                     </tr>
176                 [% END %]
177                 </tbody>
178             </table>
179         </fieldset>
180     [% ELSIF (AcqCreateItem == 'receiving') %]
181         <div id="items_list" style="display:none">
182             <p><strong>Items list</strong></p>
183             <div style="width:100%;overflow:auto;">
184                 <table>
185                     <thead>
186                         <tr>
187                             <th class="noExport">Actions</th>
188                             <th>Barcode</th>
189                             <th>Home library</th>
190                             <th>Holding library</th>
191                             <th>Not for loan</th>
192                             <th>Restricted</th>
193                             <th>Location</th>
194                             <th>Call number</th>
195                             <th>Copy number</th>
196                             <th>Inventory number</th>
197                             <th>Collection</th>
198                             <th>Item type</th>
199                             <th>Materials</th>
200                             <th>Notes</th>
201                         </tr>
202                     </thead>
203                     <tbody>
204                     </tbody>
205                 </table>
206             </div>
207         </div>
208
209         [% UNLESS order.subscriptionid %]
210           <fieldset class="rows" id="itemfieldset">
211               <legend>Item</legend>
212               [% IF ( NoACQframework ) %]
213                   <p class="required">
214                       No ACQ framework, using default. You should create a
215                       framework with code ACQ, the items framework would be
216                       used
217                   </p>
218               [% END %]
219               <div id="outeritemblock"></div>
220           </fieldset>
221         [% END %]
222     [% ELSIF (AcqCreateItem == 'ordering') %]
223         [% IF (order.items) %]
224             <div class="page-section" style="width:100%;overflow:auto">
225                 <h2>Items</h2>
226                 <table>
227                     <thead>
228                         <tr>
229                             <th>Receive?</th>
230                             <th>&nbsp;</th>
231                             <th>Barcode</th>
232                             <th>Home library</th>
233                             <th>Current library</th>
234                             <th>Not for loan</th>
235                             <th>Restricted</th>
236                             <th>Location</th>
237                             <th>Call number</th>
238                             <th>Copy number</th>
239                             <th>Inventory number</th>
240                             <th>Collection</th>
241                             <th>Item type</th>
242                             <th>Materials</th>
243                             <th>Notes</th>
244                         </tr>
245                     </thead>
246                     <tbody>
247                         [% FOREACH item IN order.items %]
248                             <tr id="item_[% item.itemnumber | html %]">
249                                 <td style="text-align:center"><input type="checkbox" name="items_to_receive" value="[% item.itemnumber | html %]" /></td>
250                                 <td><a style="cursor:pointer" onclick="PopupEditPage([% item.biblionumber | html %],[% item.itemnumber | html %]);">Edit</a></td>
251                                 <td>[% item.barcode | html %]</td>
252                                 <td>[% Branches.GetName( item.homebranch ) | html %]</td>
253                                 <td>[% Branches.GetName( item.holdingbranch ) | html %]</td>
254                                 <td>[% AuthorisedValues.GetDescriptionByKohaField( kohafield => 'items.notforloan', authorised_value => item.notforloan ) | html %]</td>
255                                 <td>[% AuthorisedValues.GetDescriptionByKohaField( kohafield => 'items.restricted', authorised_value => item.restricted ) | html %]</td>
256                                 <td><span class="shelvingloc">[% AuthorisedValues.GetDescriptionByKohaField( kohafield => 'items.location', authorised_value => item.location ) | html %]</span></td>
257                                 <td>[% item.itemcallnumber | html %]</td>
258                                 <td>[% item.copynumber | html %]</td>
259                                 <td>[% item.stocknumber | html %]</td>
260                                 <td>[% AuthorisedValues.GetDescriptionByKohaField( kohafield => 'items.ccode', authorised_value => item.ccode ) | html %]</td>
261                                 <td>[% ItemTypes.GetDescription( item.itype ) | html %]</td>
262                                 <td>[% AuthorisedValues.GetDescriptionByKohaField( kohafield => 'items.materials', authorised_value => item.materials ) | html %]</td>
263                                 <td>[% item.itemnotes | html %]</td>
264                             </tr>
265                         [% END %]
266                     </tbody>
267                 </table>
268             </div>
269         [% END %]
270     [% END %]
271     <input type="hidden" name="biblionumber" value="[% order.biblionumber | html %]" />
272     <input type="hidden" name="invoiceid" value="[% invoiceid | html %]" />
273     <input type="hidden" name="ordernumber" value="[% order.ordernumber | html %]" />
274     <input type="hidden" name="booksellerid" value="[% order.basket.booksellerid | html %]" />
275         </div>
276     <div class="col-sm-6">
277     <fieldset class="rows">
278     <legend>Accounting details</legend>
279         <ol>
280             <li>
281                 <label for="datereceived">Date received: </label>
282                 <input type="text" size="10" id="datereceived" name="datereceived" value="[% datereceived | html %]" class="flatpickr" />
283                 <div class="hint">[% INCLUDE 'date-format.inc' %]</div>
284             </li>
285        <li>
286             <label class="required" for="bookfund">Fund: </label>
287             [% active_count = 0 %]
288             [% IF !ordernumber %]
289                 [% FOREACH budget_period IN budget_loops.keys %]
290                     [% FOREACH fund IN budget_loops.$budget_period.funds %]
291                         [% active_count= active_count + fund.b_active %]
292                     [% END %]
293                 [% END %]
294             [% END %]
295             <select class="select2" id="bookfund" name="bookfund">
296                 <optgroup label="Current">
297                         <option value="[% order.fund.budget.id | html %]" selected="selected" data-sort1-authcat="[% order.fund.sort1_authcat | html %]" data-sort2-authcat="[% order.fund.sort2_authcat | html %]">
298                             Keep current ([% order.fund.budget_name | html %])</option>
299                 </optgroup>
300             [% FOREACH budget_period_id IN budget_loops.keys %]
301                 [% SET budget_period = budget_loops.$budget_period_id %]
302                 [% IF budget_period.active %]
303                     <optgroup label="[% budget_period.description | html %]">
304                 [% ELSE %]
305                     <optgroup class="inactive_budget" label="[% budget_period.description | html %] (Inactive)">
306                 [% END %]
307                 [% FOREACH budget_loo IN budget_period.funds %]
308                    [% level_indent_cnt = 0 %]
309                     [% level_indent = "" %]
310                     [% WHILE level_indent_cnt < budget_loo.b_level %]
311                         [% level_indent = level_indent _ " -- " %]
312                         [% level_indent_cnt = level_indent_cnt +1 %]
313                     [% END %]
314
315                     [% IF ( budget_loo.b_sel ) %]
316                         [% active_count = 0 #select no other fund %]
317                         <option value="[% budget_loo.b_id | html %]" selected="selected" data-sort1-authcat="[% budget_loo.b_sort1_authcat | html %]" data-sort2-authcat="[% budget_loo.b_sort2_authcat | html %]">
318                     [% ELSIF active_count==1 && budget_loo.b_active %]
319                         <option value="[% budget_loo.b_id | html %]" selected="selected" data-sort1-authcat="[% budget_loo.b_sort1_authcat | html %]" data-sort2-authcat="[% budget_loo.b_sort2_authcat | html %]">
320                     [% ELSE %]
321                         [% bdgclass=budget_loo.b_active? "": "inactive_budget" | html %]
322                         <option value="[% budget_loo.b_id | html %]" class="[% bdgclass | html %]" data-sort1-authcat="[% budget_loo.b_sort1_authcat | html %]" data-sort2-authcat="[% budget_loo.b_sort2_authcat | html %]">
323                     [% END %]
324                         [% level_indent | html %][% budget_loo.b_txt | html %][% IF !budget_loo.b_active %] (inactive)[% END %]
325                     </option>
326                 [% END %]
327                 </optgroup>
328             [% END %]
329             </select>
330             <span class="required">Required</span>
331             <label for="showallbudgets" style="float:none;">&nbsp;Show inactive:</label>
332             <input type="checkbox" id="showallbudgets" />
333        </li>
334        <li><label>&nbsp;</label><span>(Current: [% budget_period_description | html %] - [% bookfund | html %])</span></li>
335        <li>
336         <label for="creator">Ordered by: </label>
337         <span>
338             [% INCLUDE 'patron-title.inc' patron = creator %]
339         </span>
340        </li>
341        <li><label for="quantity_to_receive">Quantity ordered: </label><span class="label">
342            [% IF edit or order.subscriptionid %]
343                <input type="text" id="quantity_to_receive" name="quantity" value="[% order.quantity | html %]" />
344            [% ELSE%]
345                <input type="text" readonly="readonly" id="quantity_to_receive" name="quantity" value="[% order.quantity | html %]" />
346            [% END %]
347            </span></li>
348         <li><label for="quantity">Quantity received: </label>
349           [% IF order.subscriptionid %]
350               <input type="text" inputmode="numeric" pattern="[0-9]*" size="20" name="quantityrec" id="quantity" value="[% order.quantity | html %]" />
351               <input id="origquantityrec" readonly="readonly" type="hidden" name="origquantityrec" value="[% order.quantityreceived | html %]" />
352           [% ELSIF AcqCreateItem == 'receiving' %]
353               <input readonly="readonly" type="text" size="20" name="quantityrec" id="quantity" value="0" />
354           [% ELSE %]
355             [% IF ( order.quantityreceived ) %]
356                 [% IF ( edit ) %]
357                     <input type="text" inputmode="numeric" pattern="[0-9]*" size="20" name="quantityrec" id="quantity" value="[% order.quantityreceived | html %]" />
358                     <input id="origquantityrec" readonly="readonly" type="hidden" name="origquantityrec" value="[% order.quantityreceived | html %]" />
359                 [% ELSE %]
360                     [% IF ( order.items.count ) %]
361                         <input readonly="readonly" type="text" size="20" name="quantityrec" id="quantity" value="[% order.quantityreceived + 1 | html %]" />
362                     [% ELSE %]
363                         <input type="text" inputmode="numeric" pattern="[0-9]*" size="20" name="quantityrec" id="quantity" value="[% quantityreceived + 1 | html %]" />
364                     [% END %]
365                     <input id="origquantityrec" readonly="readonly" type="hidden" name="origquantityrec" value="[% order.quantityreceived | html %]" />
366                 [% END %]
367             [% ELSE %]
368                 <input type="text" inputmode="numeric" pattern="[0-9]*" id="quantity" size="20" name="quantityrec" value="1" />
369                 <input id="origquantityrec" readonly="readonly" type="hidden" name="origquantityrec" value="0" />
370             [% END %]
371             <div id="qtyrecerror" style="display:none">
372                 <p class="error">Warning, you have entered more items than expected.
373                 Items will not be created.</p>
374             </div>
375           [% END %][%# IF (order.subscriptionid) ELSIF (AcqCreateItem == 'receiving' ) %]
376                 </li>
377
378         [% IF ( gst_values ) %]
379             <li>
380                 <label for="tax_rate">Tax rate: </label>
381                 <select name="tax_rate" id="tax_rate">
382                 [% tax_rate = order.tax_rate_on_receiving || order.tax_rate_on_ordering %]
383                 [% tax_rate = tax_rate + 0 %]
384                 [% FOREACH gst IN gst_values %]
385                     [% IF gst.option == tax_rate %]
386                         <option value="[% gst.option | html %]" selected="selected">[% gst.option * 100 | html %]%</option>
387                     [% ELSE %]
388                         <option value="[% gst.option | html %]">[% gst.option * 100 | html %]%</option>
389                     [% END %]
390                 [% END %]
391                 </select>
392             </li>
393         [% ELSE %]
394             <input type="hidden" name="tax_rate" value="0" />
395         [% END %]
396
397         <li><label for="rrp">Retail price: </label>
398             [% IF (invoiceincgst == 1) %]
399                 [% order.rrp_tax_included | $Price %]<span class="hint">(adjusted for [% active_currency.currency | html %],tax inclusive)</span></li>
400             [% ELSE %]
401                 [% order.rrp_tax_excluded | $Price %]<span class="hint">(adjusted for [% active_currency.currency | html %],tax exclusive)</span></li>
402             [% END %]
403         <li>
404             <label for="replacementprice">Replacement price:</label>
405             <input type="text" size="20" name="replacementprice" id="replacementprice" value="[% order.replacementprice | $Price on_editing => 1 %]" />
406         </li>
407         <li>
408             [% IF (invoiceincgst) %]
409                 <label for="ecost">Budgeted cost: </label>[% order.ecost_tax_included | $Price %] <span class="hint">(tax inclusive)</span>
410             [% ELSE %]
411                 <label for="ecost">Budgeted cost: </label>[% order.ecost_tax_excluded | $Price %] <span class="hint">(tax exclusive)</span>
412             [% END %]
413             </li>
414         <li>
415             <label for="unitprice">Actual cost:</label>
416             [% IF (invoiceincgst) %]
417                 [% SET unitprice = order.unitprice_tax_included > 0 ? order.unitprice_tax_included : order.ecost_tax_included %]
418                 <input type="text" size="20" name="unitprice" id="unitprice" value="[% unitprice | $Price on_editing => 1 %]" /> <span class="hint">(tax inclusive)</span>
419             [% ELSE %]
420                 [% SET unitprice = order.unitprice_tax_included > 0 ? order.unitprice_tax_excluded : order.ecost_tax_excluded %]
421                 <input type="text" size="20" name="unitprice" id="unitprice" value="[% unitprice | $Price on_editing => 1 %]" /> <span class="hint">(tax exclusive)</span>
422             [% END %]
423             <label style="font-weight: inherit; float:none;"><input type="checkbox" name="change_currency">Change currency</label>
424         </li>
425         <li id="select_currency">
426             <label for="unitprice_currency"></label>
427             <input type="text" size="20" name="unitprice" id="unitprice_currency" value="" />
428             [% IF currencies.count %]
429                 <select name="currency">
430                     <option value="[% active_currency.rate | html %]" selected="selected">[% active_currency.currency | html %] ([% active_currency.symbol | html %])</option>
431                     [% FOR currency IN currencies %]
432                         <option value="[% currency.rate | html %]">[% currency.currency | html %] ([% currency.symbol | html %])</option>
433                     [% END %]
434                 </select>
435             [% END %]
436         </li>
437         <li><label for="order_internalnote">Internal note: </label><textarea name="order_internalnote" width="40" rows="8" >[% order_internalnote | html %]</textarea></li>
438         [% IF order_vendornote %]
439             <li><label for="order_vendornote">Vendor note: </label><span>[% order_vendornote | html %]</span></li>
440         [% END %]
441         </ol>
442     </fieldset>
443
444 </div>
445 </div><div class="row"><fieldset class="action">
446         <input type="submit" value="Save" class="btn btn-primary" accesskey="w" />
447         <a class="cancel" href="/cgi-bin/koha/acqui/parcel.pl?invoiceid=[% invoiceid | html %]">Cancel</a>
448 </fieldset></div>    </form>
449 [% ELSE %]
450     This ordernumber does not exist.
451 [% END %]
452
453 </main>
454 </div> <!-- /.col-sm-10.col-sm-push-2 -->
455
456 <div class="col-sm-2 col-sm-pull-10">
457     <aside>
458         [% INCLUDE 'acquisitions-menu.inc' %]
459     </aside>
460 </div> <!-- /.col-sm-2.col-sm-pull-10 -->
461 </div> <!-- /.row -->
462 [% MACRO jsinclude BLOCK %]
463     [% Asset.js("js/acquisitions-menu.js") | $raw %]
464 [% INCLUDE 'calendar.inc' %]
465     [% Asset.js("js/additem.js") | $raw %]
466     [% Asset.js("js/cataloging.js") | $raw %]
467     [% INCLUDE 'select2.inc' %]
468     <script>
469         function Check(form) {
470             [% IF (AcqCreateItem == 'receiving') %]
471                 var total_errors = CheckMandatorySubfields(form);
472                 if (total_errors != 0) {
473                     var alertString = _("Form not submitted because of the following problem(s)");
474                     alertString += "\n------------------------------------------------------------------------------------\n";
475                     alertString += "\n- " + _("%s mandatory fields empty (highlighted)").format(total_errors);
476                     alert(alertString);
477                     return false;
478                 }
479
480                 if(check_additem('[% Koha.Preference("UniqueItemFields") | html %]') == false){
481                     alert(_("Duplicate values detected. Please correct the errors and resubmit.") );
482                     return false;
483                 };
484
485                 // Remove last itemblock if it is not in items_list
486                 var lastitemblock = $("#outeritemblock > div:last");
487                 var tobedeleted = true;
488                 var listitems = $("#items_list tr");
489                 $(listitems).each(function(){
490                     if($(this).attr('idblock') == $(lastitemblock).attr('id')){
491                         tobedeleted = false;
492                     }
493                 });
494                 if(tobedeleted){
495                     $(lastitemblock).remove();
496                 }
497
498                 if(check_additem('[% Koha.Preference("UniqueItemFields") | html %]') == false){
499                     alert(_("Duplicate values detected. Please correct the errors and resubmit.") );
500                     if(tobedeleted) {
501                         $(lastitemblock).appendTo("#outeritemblock");
502                     }
503                     return false;
504                 };
505             [% END %]
506
507             if( $("#quantity").val() < 1 ) {
508                 alert(_("You must receive at least one item"));
509                 return false;
510             }
511
512             return true;
513         }
514
515         [% IF (AcqCreateItem == 'ordering') %]
516             var items_columns = [null, null, 'barcode', 'homebranchname',
517                 'holdingbranchname', 'notforloan', 'restricted', 'location',
518                 'itemcallnumber', 'copynumber', 'stocknumber', 'collection',
519                 'itemtype', 'materials', 'itemnotes'];
520
521             function PopupEditPage(biblionumber, itemnumber) {
522                 var url = "/cgi-bin/koha/cataloguing/additem.pl?op=edititem&biblionumber="
523                     + biblionumber + "&itemnumber=" + itemnumber + "&popup=1#edititem";
524                 var w = window.open(url);
525                 var watchClose = setInterval(function() {
526                     if (w.closed) {
527                         clearTimeout(watchClose);
528                         $.getJSON('/cgi-bin/koha/catalogue/getitem-ajax.pl',
529                             {
530                                 'itemnumber': itemnumber
531                             },
532                             function(item) {
533                                 var tds = $("#item_"+itemnumber+" td");
534                                 for(var i=2; i<tds.length; i++) {
535                                     var column = items_columns[i];
536                                     var text = item[column];
537                                     if ( text == null ) text = '';
538                                     $(tds[i]).text(text);
539                                 }
540                             }
541                         );
542                     }
543                 }, 500);
544             }
545
546             function CalcQtyToReceive() {
547                 var qty = $("input[name='items_to_receive']:checked").length;
548                 $("#quantity").val(qty);
549             }
550
551             function CheckNItems(n) {
552                 $("input[name='items_to_receive']").each(function() {
553                     $(this).prop('checked', false);
554                 });
555                 $("input[name='items_to_receive']:lt("+n+")").each(function () {
556                     $(this).prop('checked', true);
557                 });
558             }
559         [% END %]
560
561         $(document).ready(function() {
562
563             //keep a copy of all budgets before removing the inactives
564             disabledBudgetsCopy = $('#bookfund').html();
565             $('#bookfund .inactive_budget').remove();
566
567             $('#showallbudgets').click(function() {
568                 if ($(this).is(":checked")) {
569                     $('#bookfund').html(disabledBudgetsCopy); //Puts back all the funds
570                 }
571                 else {
572                     $('#bookfund .inactive_budget').remove();
573                 }
574             });
575
576             [% IF (AcqCreateItem == 'receiving') %]
577                 cloneItemBlock(0, '[% Koha.Preference('UniqueItemFields') | html %]');
578             [% ELSIF (AcqCreateItem == 'ordering') && not order.subscriptionid %]
579                 $("input[name='items_to_receive']").change(function() {
580                     CalcQtyToReceive();
581                 });
582                 CalcQtyToReceive();
583                 $("#quantity").keyup(function() {
584                     var qty = parseInt($("#quantity").val());
585                     var qtyto = parseInt($("#quantity_to_receive").val());
586                     if(qty > qtyto) {
587                         $("#qtyrecerror").show();
588                     } else {
589                         $("#qtyrecerror").hide();
590                     }
591                     CheckNItems($(this).val());
592                 });
593             [% END %]
594
595             $("input[name='change_currency']").on("change", function(){
596                 if ( $(this).is(":checked") ) {
597                     $("#select_currency").show();
598                     $("#unitprice").prop("readonly", "true");
599                 } else {
600                     $("#select_currency").hide();
601                     $("#unitprice").prop("readonly", "");
602                 }
603             }).change();
604
605             function update_unitprice() {
606                 var rate = Number($("select[name='currency'] option:selected").val());
607                 var unitprice = $("#unitprice_currency").val();
608                 var new_unitprice = Number( unitprice * rate ).toFixed(2);
609                 $("#unitprice").val(new_unitprice);
610             }
611             $("select[name='currency']").on("change", function(){update_unitprice()} );
612             $("#unitprice_currency").on("change", function(){update_unitprice()} );
613
614             [% IF other_reason %]
615                 $(".select-reason").hide();
616                 $(".select-reason").find("option[value='other']").attr("selected","selected");
617                 $("#other_reason").show();
618             [% ELSE %]
619                 $("#other_reason").hide();
620             [% END %]
621             $(".select-reason").change(function(){
622                 if($(this).val() == "other"){
623                     $(this).hide();
624                     $("#other_reason").show();
625                 }
626             });
627             $("a[href*=back]").click(function(){
628                 $(".select-reason").show().find("option[value='']").attr("selected","selected");
629                 $("#other_reason").hide();
630             });
631
632         });
633     </script>
634 [% END %]
635
636 [% INCLUDE 'intranet-bottom.inc' %]