X-Git-Url: http://wagnertech.de/gitweb/gitweb.cgi/mfinanz.git/blobdiff_plain/92f6fae1e8c4861460ae364ac7dc243b429a9cb6..671a5253d0c37a057f1fdf5d6588b648c7af4a82:/SL/Controller/Order.pm diff --git a/SL/Controller/Order.pm b/SL/Controller/Order.pm index a79e3653c..8d2e972c1 100644 --- a/SL/Controller/Order.pm +++ b/SL/Controller/Order.pm @@ -13,10 +13,12 @@ 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; use SL::DB::Part; +use SL::DB::PartClassification; use SL::DB::PartsGroup; use SL::DB::Printer; use SL::DB::Language; @@ -43,7 +45,7 @@ use Sort::Naturally; use Rose::Object::MakeMethods::Generic ( scalar => [ qw(item_ids_to_delete is_custom_shipto_to_delete) ], - 'scalar --get_set_init' => [ qw(order valid_types type cv p all_price_factors search_cvpartnumber show_update_button) ], + 'scalar --get_set_init' => [ qw(order valid_types type cv p all_price_factors search_cvpartnumber show_update_button part_picker_classification_ids) ], ); @@ -345,7 +347,12 @@ sub action_print { $self->js->flash('error', t8('Storing PDF in storage backend failed: #1', $@)); } } - $self->js->render; + + $self->save_history('PRINTED'); + + $self->js + ->run('kivi.ActionBar.setEnabled', '#save_and_email_action') + ->render; } # open the email dialog @@ -465,6 +472,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 = ( @@ -1170,6 +1179,13 @@ sub init_all_price_factors { SL::DB::Manager::PriceFactor->get_all; } +sub init_part_picker_classification_ids { + my ($self) = @_; + my $attribute = 'used_for_' . ($self->type =~ m{sales} ? 'sale' : 'purchase'); + + return [ map { $_->id } @{ SL::DB::Manager::PartClassification->get_all(where => [ $attribute => 1 ]) } ]; +} + sub check_auth { my ($self) = @_; @@ -1537,6 +1553,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); @@ -1584,6 +1602,9 @@ sub save { } } } + + $self->save_history('SAVED'); + 1; }) || push(@{$errors}, $db->error); @@ -1758,7 +1779,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; } @@ -1842,6 +1863,7 @@ sub setup_edit_action_bar { ], action => [ t8('Save and E-mail'), + id => 'save_and_email_action', call => [ 'kivi.Order.save', 'save_and_show_email_dialog', $::instance_conf->get_order_warn_duplicate_parts ], disabled => !$self->order->id ? t8('This object has not been saved yet.') : undef, ], @@ -1871,6 +1893,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" ); } @@ -2098,6 +2125,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__ @@ -2211,8 +2253,6 @@ java script functions =item * testing -=item * credit limit - =item * price sources: little symbols showing better price / better discount =item * select units in input row? @@ -2223,8 +2263,6 @@ java script functions =item * display weights -=item * history - =item * mtime check =item * optional client/user behaviour