->val('#add_item_discount_as_percent', '')
->run('row_table_scroll_down')
->run('row_set_keyboard_events_by_id', $item_id)
+ ->on('.recalc', 'change', 'recalc_amounts_and_taxes')
->focus('#add_item_parts_id_name');
$self->_js_redisplay_amounts_and_taxes;
$self->_recalc();
+ $self->_js_redisplay_linetotals;
$self->_js_redisplay_amounts_and_taxes;
$self->js->render($self);
}
+sub _js_redisplay_linetotals {
+ my ($self) = @_;
+
+ my @data = map {$::form->format_amount(\%::myconfig, $_->{linetotal}, 2, 0)} @{ $self->order->items };
+ $self->js
+ ->run('redisplay_linetotals', \@data);
+}
+
sub _js_redisplay_amounts_and_taxes {
my ($self) = @_;
[%- L.input_tag("order.orderitems[].qty_as_number",
ITEM.qty_as_number,
size = 5,
- style='text-align:right') %]
+ style='text-align:right',
+ class="recalc") %]
</td>
<td>
[%- L.input_tag("order.orderitems[].price_factor",
ITEM.price_factor,
size = 5,
- style='text-align:right') %]
+ style='text-align:right',
+ class="recalc") %]
</td>
<td nowrap>
[%- L.input_tag("order.orderitems[].unit",
ITEM.unit,
- size = 5) %]
+ size = 5,
+ class="recalc") %]
</td>
<td>
[%- L.input_tag("order.orderitems[].sellprice_as_number",
ITEM.sellprice_as_number,
size = 10,
- style='text-align:right') %]
+ style='text-align:right',
+ class="recalc") %]
</td>
<td>
[%- L.input_tag("order.orderitems[].discount_as_percent",
ITEM.discount_as_percent,
size = 5,
- style='text-align:right') %]
+ style='text-align:right',
+ class="recalc") %]
</td>
<td align="right">
[%- L.div_tag(LxERP.format_amount(ITEM.linetotal, 2, 0), name="linetotal") %]
$.post("controller.pl", data, kivi.eval_json_result);
}
+function redisplay_linetotals(data) {
+ $('.row_entry [name="linetotal"]').each(function(idx, elt) {
+ $(elt).html(data[idx]);
+ });
+}
+
function row_table_scroll_down() {
$('#row_table_scroll_id').scrollTop($('#row_table_scroll_id')[0].scrollHeight);
}
}
});
row_set_keyboard_events($('.row_entry'));
+ $('.recalc').change(recalc_amounts_and_taxes);
});
</script>