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