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