From db7ddbbe88d50488f5d1f5a09ab2d3455f614e7f Mon Sep 17 00:00:00 2001 From: Moritz Bunkus Date: Wed, 10 Feb 2021 12:43:10 +0100 Subject: [PATCH] Order-Controller: Historienfunktion implementiert (aufzeichnen & anzeigen) --- SL/Controller/Order.pm | 35 ++++++++++++++++++++++++++++++++--- 1 file changed, 32 insertions(+), 3 deletions(-) diff --git a/SL/Controller/Order.pm b/SL/Controller/Order.pm index d8887e03c..0fb8dc2ee 100644 --- a/SL/Controller/Order.pm +++ b/SL/Controller/Order.pm @@ -13,6 +13,7 @@ use SL::File; use SL::MIME; use SL::Util qw(trim); use SL::YAML; +use SL::DB::History; use SL::DB::Order; use SL::DB::Default; use SL::DB::Unit; @@ -346,6 +347,9 @@ sub action_print { $self->js->flash('error', t8('Storing PDF in storage backend failed: #1', $@)); } } + + $self->save_history('PRINTED'); + $self->js->render; } @@ -466,6 +470,8 @@ sub action_send_email { $self->order->update_attributes(intnotes => $intnotes); + $self->save_history('MAILED'); + flash_later('info', t8('The email has been sent.')); my @redirect_params = ( @@ -1545,6 +1551,8 @@ sub delete { my $spool = $::lx_office_conf{paths}->{spool}; unlink map { "$spool/$_" } @spoolfiles if $spool; + $self->save_history('DELETED'); + 1; }) || push(@{$errors}, $db->error); @@ -1592,6 +1600,9 @@ sub save { } } } + + $self->save_history('SAVED'); + 1; }) || push(@{$errors}, $db->error); @@ -1766,7 +1777,7 @@ sub pre_render { $self->get_item_cvpartnumber($_) for @{$self->order->items_sorted}; $::request->{layout}->use_javascript("${_}.js") for qw(kivi.SalesPurchase kivi.Order kivi.File ckeditor/ckeditor ckeditor/adapters/jquery - edit_periodic_invoices_config calculate_qty kivi.Validator follow_up); + edit_periodic_invoices_config calculate_qty kivi.Validator follow_up show_history); $self->setup_edit_action_bar; } @@ -1879,6 +1890,11 @@ sub setup_edit_action_bar { disabled => !$self->order->id ? t8('This object has not been saved yet.') : undef, only_if => $::auth->assert('productivity', 1), ], + action => [ + t8('History'), + call => [ 'set_history_window', $self->order->id, 'id' ], + disabled => !$self->order->id ? t8('This record has not been saved yet.') : undef, + ], ], # end of combobox "more" ); } @@ -2106,6 +2122,21 @@ sub save_and_redirect_to { $self->redirect_to(%params, id => $self->order->id); } +sub save_history { + my ($self, $addition) = @_; + + my $number_type = $self->order->type =~ m{order} ? 'ordnumber' : 'quonumber'; + my $snumbers = $number_type . '_' . $self->order->$number_type; + + SL::DB::History->new( + trans_id => $self->order->id, + employee_id => SL::DB::Manager::Employee->current->id, + what_done => $self->order->type, + snumbers => $snumbers, + addition => $addition, + )->save; +} + 1; __END__ @@ -2229,8 +2260,6 @@ java script functions =item * display weights -=item * history - =item * mtime check =item * optional client/user behaviour -- 2.20.1