my $order = $results->[0];
my $order_object = Koha::Acquisition::Orders->find( $ordernumber );
my $basket = $order_object->basket;
-my $active_currency = Koha::Acquisition::Currencies->get_active;
+my $currencies = Koha::Acquisition::Currencies->search;
+my $active_currency = $currencies->get_active;
# Check if ACQ framework exists
my $acq_fw = GetMarcStructure( 1, 'ACQ', { unsafe => 1 } );
booksellerid => $order->{'booksellerid'},
freight => $freight,
name => $bookseller->name,
- cur_active_sym => $active_currency->symbol,
- cur_active => $active_currency->currency,
+ active_currency => $active_currency,
+ currencies => scalar $currencies->search({ rate => { '!=' => 1 } }),
invoiceincgst => $bookseller->invoiceincgst,
title => $order->{'title'},
author => $order->{'author'},
<input type="hidden" name="tax_rate" value="0" />
[% END %]
- <li><label for="rrp">Retail price: </label>[% rrp | $Price %] <span class="hint">(adjusted for [% cur_active | html %], [% IF (invoiceincgst == 1) %]tax inclusive[% ELSE %]tax exclusive[% END %])</span></li>
+ <li><label for="rrp">Retail price: </label>[% rrp | $Price %] <span class="hint">(adjusted for [% active_currency.currency | html %], [% IF (invoiceincgst == 1) %]tax inclusive[% ELSE %]tax exclusive[% END %])</span></li>
<li>
<label for="replacementprice">Replacement price:</label>
<input type="text" size="20" name="replacementprice" id="replacementprice" value="[% replacementprice | $Price on_editing => 1 %]" />
<li><label for="ecost">Budgeted cost: </label>[% ecost | $Price %] <span class="hint">[% IF (invoiceincgst == 1) %](tax inclusive)[% ELSE %](tax exclusive)[% END %]</span></li>
<li>
<label for="unitprice">Actual cost:</label>
- <input type="text" size="20" name="unitprice" id="unitprice" value="[% unitprice | $Price on_editing => 1 %]" /> <span class="hint">[% IF (invoiceincgst == 1) %](tax inclusive)[% ELSE %](tax exclusive)[% END %]</span>
+ <input type="text" size="20" name="unitprice" id="unitprice" value="[% unitprice | $Price on_editing => 1 %]" />
+ <span class="hint">[% IF (invoiceincgst == 1) %](tax inclusive)[% ELSE %](tax exclusive)[% END %]</span>
+ <label style="font-weight: inherit; float:none;"><input type="checkbox" name="change_currency">Change currency</label>
+ </li>
+ <li id="select_currency">
+ <label for="unitprice_currency"></label>
+ <input type="text" size="20" name="unitprice" id="unitprice_currency" value="" />
+ [% IF currencies.count %]
+ <select name="currency">
+ <option value="[% active_currency.rate %]" selected="selected">[% active_currency.currency %] ([% active_currency.symbol %])</option>
+ [% FOR currency IN currencies %]
+ <option value="[% currency.rate %]">[% currency.currency %] ([% currency.symbol %])</option>
+ [% END %]
+ </select>
+ [% END %]
</li>
<li><label for="order_internalnote">Internal note: </label><textarea name="order_internalnote" width="40" rows="8" >[% order_internalnote | html %]</textarea></li>
[% IF order_vendornote %]
CheckNItems($(this).val());
});
[% END %]
+
+ $("input[name='change_currency']").on("change", function(){
+ if ( $(this).is(":checked") ) {
+ $("#select_currency").show();
+ $("#unitprice").prop("readonly", "true");
+ } else {
+ $("#select_currency").hide();
+ $("#unitprice").prop("readonly", "");
+ }
+ }).change();
+
+ function update_unitprice() {
+ var rate = Number($("select[name='currency'] option:selected").val());
+ var unitprice = $("#unitprice_currency").val();
+ var new_unitprice = Number( unitprice * rate ).toFixed(2);
+ $("#unitprice").val(new_unitprice);
+ }
+ $("select[name='currency']").on("change", function(){update_unitprice()} );
+ $("#unitprice_currency").on("change", function(){update_unitprice()} );
});
</script>
[% END %]