sub action_save {
my ($self) = @_;
- $self->_save();
+ my $errors = $self->_save();
+ if (scalar @{ $errors }) {
+ $self->js->flash('error', $_) foreach @{ $errors };
+ return $self->js->render($self);
+ }
+
+ flash_later('info', 'The order has been saved');
my @redirect_params = (
action => 'edit',
type => $self->type,
sub _save {
my ($self) = @_;
+ my $errors = [];
my $db = $self->order->db;
$db->do_transaction(
sub {
$self->order->save();
- }) || die($db->error);
+ }) || push(@{$errors}, $db->error);
+
+ return $errors;
}
[% L.hidden_tag('action', 'Order/dispatch') %]
- [% L.submit_tag('action_update', LxERP.t8('Update')) %]
- [% L.submit_tag('action_save', LxERP.t8('Save')) %]
+ [% L.button_tag('save()', LxERP.t8('Save')) %]</td>
</form>
+
+
+<script type='text/javascript'>
+
+function save() {
+ var data = $('#order_form').serialize();
+ data += '&action=Order/save';
+
+ $.post("controller.pl", data, kivi.eval_json_result);
+}
+
+</script>