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