|
Lines 365-371
Link Here
|
| 365 |
<span id="unitprice_hint" class="hint"></span> |
365 |
<span id="unitprice_hint" class="hint"></span> |
| 366 |
</li> |
366 |
</li> |
| 367 |
<li> |
367 |
<li> |
| 368 |
<label style="margin-left: 12em; text-align: left; font-weight: inherit; float:none;"><input type="checkbox" name="change_currency">Change currency</label> |
368 |
<label style="margin-left: 12em; text-align: left; font-weight: inherit; float:none;"><input type="checkbox" id="change_currency" name="change_currency">Change currency</label> |
| 369 |
</li> |
369 |
</li> |
| 370 |
<li id="select_currency"> |
370 |
<li id="select_currency"> |
| 371 |
<label for="invoice_unitprice"></label> |
371 |
<label for="invoice_unitprice"></label> |
|
Lines 909-940
Link Here
|
| 909 |
|
909 |
|
| 910 |
}); |
910 |
}); |
| 911 |
|
911 |
|
| 912 |
$("#order_edit").on("change", "input[name='change_currency']", function(){ |
912 |
function _update_unitprice() { |
| 913 |
if ( $(this).is(":checked") ) { |
913 |
let row = $("#order_edit").data('row'); |
|
|
914 |
|
| 915 |
let unitprice = $("#unitprice").val(); |
| 916 |
let invoice_currency = $("#invoice_currency").val(); |
| 917 |
let invoice_unitprice = $("#invoice_unitprice").val(); |
| 918 |
let change_currency = $("#change_currency").is(":checked"); |
| 919 |
|
| 920 |
if ( change_currency ) { |
| 914 |
$("#select_currency").show(); |
921 |
$("#select_currency").show(); |
| 915 |
if(!$("#invoice_unitprice").val()) |
922 |
if(!$("#invoice_unitprice").val()){ |
| 916 |
$("#invoice_unitprice").val($('#unitprice').val()); |
923 |
invoice_unitprice = unitprice; |
|
|
924 |
} |
| 925 |
var rate = Number($("#invoice_currency option:selected").data('rate')); |
| 926 |
unitprice = Number( invoice_unitprice * rate ).toFixed(2); |
| 917 |
$("#unitprice").prop("readonly", "true"); |
927 |
$("#unitprice").prop("readonly", "true"); |
| 918 |
} else { |
928 |
} else { |
| 919 |
$("#select_currency").hide(); |
929 |
$("#select_currency").hide(); |
| 920 |
$("#unitprice").prop("readonly", ""); |
930 |
$("#unitprice").prop("readonly", ""); |
| 921 |
$("#invoice_unitprice").val(""); |
931 |
invoice_unitprice = ""; |
| 922 |
$("#invoice_currency").val(active_currency); |
932 |
invoice_currency = active_currency; |
| 923 |
} |
933 |
} |
| 924 |
}); |
|
|
| 925 |
|
934 |
|
| 926 |
function _update_unitprice() { |
935 |
$("#invoice_unitprice").val(invoice_unitprice); |
| 927 |
var row = $("#order_edit").data('row'); |
936 |
$("#invoice_currency").val(invoice_currency); |
| 928 |
var rate = Number($("select[name='invoice_currency'] option:selected").data('rate')); |
|
|
| 929 |
var invoice_currency = $("select[name='invoice_currency'] option:selected").val(); |
| 930 |
var invoice_unitprice = $("#invoice_unitprice").val(); |
| 931 |
var unitprice = Number( invoice_unitprice * rate ).toFixed(2); |
| 932 |
$("#unitprice").val(unitprice).change(); |
937 |
$("#unitprice").val(unitprice).change(); |
|
|
938 |
|
| 933 |
row.invoice_currency = invoice_currency; |
939 |
row.invoice_currency = invoice_currency; |
| 934 |
row.invoice_unit_price = invoice_unitprice; |
940 |
row.invoice_unit_price = invoice_unitprice; |
| 935 |
} |
941 |
} |
| 936 |
$("#order_edit").on("change", "select[name='invoice_currency']", _update_unitprice ); |
942 |
$("#order_edit").on("change", "#invoice_currency", _update_unitprice ); |
| 937 |
$("#order_edit").on("change", "#invoice_unitprice", _update_unitprice ); |
943 |
$("#order_edit").on("change", "#invoice_unitprice", _update_unitprice ); |
|
|
944 |
$("#order_edit").on("change", "#change_currency", _update_unitprice ); |
| 938 |
|
945 |
|
| 939 |
$("#order_edit").on("change", "#replacementprice", function() { |
946 |
$("#order_edit").on("change", "#replacementprice", function() { |
| 940 |
var val = $(this).val(); |
947 |
var val = $(this).val(); |
|
Lines 1247-1259
Link Here
|
| 1247 |
if(row.invoice_currency && row.invoice_currency != active_currency) { |
1254 |
if(row.invoice_currency && row.invoice_currency != active_currency) { |
| 1248 |
$("#select_currency").show(); |
1255 |
$("#select_currency").show(); |
| 1249 |
$("#unitprice").prop("readonly", true); |
1256 |
$("#unitprice").prop("readonly", true); |
| 1250 |
$("input[name='change_currency']").prop('checked', true); |
1257 |
$("#change_currency").prop('checked', true); |
| 1251 |
$("#invoice_currency").val(row.invoice_currency); |
1258 |
$("#invoice_currency").val(row.invoice_currency); |
| 1252 |
$("#invoice_unitprice").val(row.invoice_unit_price); |
1259 |
$("#invoice_unitprice").val(row.invoice_unit_price); |
| 1253 |
} else { |
1260 |
} else { |
| 1254 |
$("#select_currency").hide(); |
1261 |
$("#select_currency").hide(); |
| 1255 |
$("#unitprice").prop("readonly", ""); |
1262 |
$("#unitprice").prop("readonly", ""); |
| 1256 |
$("input[name='change_currency']").prop('checked', false); |
1263 |
$("#change_currency").prop('checked', false); |
| 1257 |
$("#invoice_currency").val(active_currency); |
1264 |
$("#invoice_currency").val(active_currency); |
| 1258 |
$("#invoice_unitprice").val(''); |
1265 |
$("#invoice_unitprice").val(''); |
| 1259 |
} |
1266 |
} |
| 1260 |
- |
|
|