X-Git-Url: http://wagnertech.de/git?a=blobdiff_plain;f=SL%2FController%2FOrder.pm;h=b14d764384ab7446861dedd257c35e564b565a75;hb=ee03d15d22eebae4c5224bd68a23b6b4d8a466c0;hp=5b49c4d15df7de4d0bde62e7dbb5237af8d33229;hpb=ef0dc3865ba7fc827c761cb2814cc16203cb2d58;p=kivitendo-erp.git diff --git a/SL/Controller/Order.pm b/SL/Controller/Order.pm index 5b49c4d15..b14d76438 100644 --- a/SL/Controller/Order.pm +++ b/SL/Controller/Order.pm @@ -4,6 +4,7 @@ use strict; use parent qw(SL::Controller::Base); use SL::Helper::Flash qw(flash_later); +use SL::HTML::Util; use SL::Presenter::Tag qw(select_tag hidden_tag div_tag); use SL::Locale::String qw(t8); use SL::SessionFile::Random; @@ -56,11 +57,11 @@ use Rose::Object::MakeMethods::Generic __PACKAGE__->run_before('check_auth'); __PACKAGE__->run_before('recalc', - only => [ qw(save save_as_new save_and_delivery_order save_and_invoice save_and_ap_transaction + only => [ qw(save save_as_new save_and_delivery_order save_and_invoice save_and_invoice_for_advance_payment save_and_final_invoice save_and_ap_transaction print send_email) ]); __PACKAGE__->run_before('get_unalterable_data', - only => [ qw(save save_as_new save_and_delivery_order save_and_invoice save_and_ap_transaction + only => [ qw(save save_as_new save_and_delivery_order save_and_invoice save_and_invoice_for_advance_payment save_and_final_invoice save_and_ap_transaction print send_email) ]); # @@ -300,7 +301,8 @@ sub action_print { my $doc_filename = $form->generate_attachment_filename(); my $doc; - my @errors = $self->generate_doc(\$doc, { format => $format, + my @errors = $self->generate_doc(\$doc, { media => $media, + format => $format, formname => $formname, language => $self->order->language, printer_id => $printer_id, @@ -367,7 +369,8 @@ sub action_preview_pdf { my $pdf_filename = $form->generate_attachment_filename(); my $pdf; - my @errors = $self->generate_doc(\$pdf, { format => $format, + my @errors = $self->generate_doc(\$pdf, { media => $media, + format => $format, formname => $formname, language => $self->order->language, }); @@ -513,18 +516,20 @@ sub action_send_email { $::form->{id} = $self->order->id; # this is used in SL::Mailer to create a linked record to the mail $::form->send_email(\%::myconfig, $::form->{print_options}->{format}); - # internal notes - my $intnotes = $self->order->intnotes; - $intnotes .= "\n\n" if $self->order->intnotes; - $intnotes .= t8('[email]') . "\n"; - $intnotes .= t8('Date') . ": " . $::locale->format_date_object(DateTime->now_local, precision => 'seconds') . "\n"; - $intnotes .= t8('To (email)') . ": " . $::form->{email} . "\n"; - $intnotes .= t8('Cc') . ": " . $::form->{cc} . "\n" if $::form->{cc}; - $intnotes .= t8('Bcc') . ": " . $::form->{bcc} . "\n" if $::form->{bcc}; - $intnotes .= t8('Subject') . ": " . $::form->{subject} . "\n\n"; - $intnotes .= t8('Message') . ": " . $::form->{message}; + # internal notes unless no email journal + unless ($::instance_conf->get_email_journal) { + my $intnotes = $self->order->intnotes; + $intnotes .= "\n\n" if $self->order->intnotes; + $intnotes .= t8('[email]') . "\n"; + $intnotes .= t8('Date') . ": " . $::locale->format_date_object(DateTime->now_local, precision => 'seconds') . "\n"; + $intnotes .= t8('To (email)') . ": " . $::form->{email} . "\n"; + $intnotes .= t8('Cc') . ": " . $::form->{cc} . "\n" if $::form->{cc}; + $intnotes .= t8('Bcc') . ": " . $::form->{bcc} . "\n" if $::form->{bcc}; + $intnotes .= t8('Subject') . ": " . $::form->{subject} . "\n\n"; + $intnotes .= t8('Message') . ": " . SL::HTML::Util->strip($::form->{message}); - $self->order->update_attributes(intnotes => $intnotes); + $self->order->update_attributes(intnotes => $intnotes); + } $self->save_history('MAILED'); @@ -566,6 +571,23 @@ sub action_show_periodic_invoices_config_dialog { language_id => $::form->{language_id}, translation_type =>"preset_text_periodic_invoices_email_body"), ); + # for older configs, replace email preset text if not yet set. + $config->email_subject(GenericTranslations->get( + language_id => $::form->{language_id}, + translation_type =>"preset_text_periodic_invoices_email_subject") + ) unless $config->email_subject; + + $config->email_body(GenericTranslations->get( + language_id => $::form->{language_id}, + translation_type => "salutation_general") + . GenericTranslations->get( + language_id => $::form->{language_id}, + translation_type => "salutation_punctuation_mark") . "\n\n" + . GenericTranslations->get( + language_id => $::form->{language_id}, + translation_type =>"preset_text_periodic_invoices_email_body") + ) unless $config->email_body; + $config->periodicity('m') if none { $_ eq $config->periodicity } @SL::DB::PeriodicInvoicesConfig::PERIODICITIES; $config->order_value_periodicity('p') if none { $_ eq $config->order_value_periodicity } ('p', @SL::DB::PeriodicInvoicesConfig::ORDER_VALUE_PERIODICITIES); @@ -659,6 +681,16 @@ sub action_save_and_delivery_order { ); } +sub action_save_and_supplier_delivery_order { + my ($self) = @_; + + $self->save_and_redirect_to( + controller => 'controller.pl', + action => 'DeliveryOrder/add_from_order', + type => 'supplier_delivery_order', + ); +} + # save the order and redirect to the frontend subroutine for a new # invoice sub action_save_and_invoice { @@ -670,6 +702,26 @@ sub action_save_and_invoice { ); } +sub action_save_and_invoice_for_advance_payment { + my ($self) = @_; + + $self->save_and_redirect_to( + controller => 'oe.pl', + action => 'oe_invoice_from_order', + new_invoice_type => 'invoice_for_advance_payment', + ); +} + +sub action_save_and_final_invoice { + my ($self) = @_; + + $self->save_and_redirect_to( + controller => 'oe.pl', + action => 'oe_invoice_from_order', + new_invoice_type => 'final_invoice', + ); +} + # workflow from sales order to sales quotation sub action_sales_quotation { $_[0]->workflow_sales_or_request_for_quotation(); @@ -1956,6 +2008,18 @@ sub setup_edit_action_bar { my @req_trans_cost_art = qw(kivi.Order.check_transport_cost_article_presence) x!!$::instance_conf->get_transport_cost_reminder_article_number_id; my @req_cusordnumber = qw(kivi.Order.check_cusordnumber_presence) x($self->type eq sales_order_type() && $::instance_conf->get_order_warn_no_cusordnumber); + my $has_invoice_for_advance_payment; + if ($self->order->id && $self->type eq sales_order_type()) { + my $lr = $self->order->linked_records(direction => 'to', to => ['Invoice']); + $has_invoice_for_advance_payment = any {'SL::DB::Invoice' eq ref $_ && "invoice_for_advance_payment" eq $_->type} @$lr; + } + + my $has_final_invoice; + if ($self->order->id && $self->type eq sales_order_type()) { + my $lr = $self->order->linked_records(direction => 'to', to => ['Invoice']); + $has_final_invoice = any {'SL::DB::Invoice' eq ref $_ && "final_invoice" eq $_->type} @$lr; + } + for my $bar ($::request->layout->get('actionbar')) { $bar->add( combobox => [ @@ -2015,6 +2079,16 @@ sub setup_edit_action_bar { ], only_if => (any { $self->type eq $_ } (sales_order_type(), purchase_order_type())) ], + action => [ + t8('Save and Supplier Delivery Order'), + call => [ 'kivi.Order.save', 'save_and_supplier_delivery_order', $::instance_conf->get_order_warn_duplicate_parts, + $::instance_conf->get_order_warn_no_deliverydate, + ], + checks => [ 'kivi.Order.check_save_active_periodic_invoices', + @req_trans_cost_art, @req_cusordnumber, + ], + only_if => (any { $self->type eq $_ } (purchase_order_type())) + ], action => [ t8('Save and Invoice'), call => [ 'kivi.Order.save', 'save_and_invoice', $::instance_conf->get_order_warn_duplicate_parts ], @@ -2022,6 +2096,26 @@ sub setup_edit_action_bar { @req_trans_cost_art, @req_cusordnumber, ], ], + action => [ + ($has_invoice_for_advance_payment ? t8('Save and Further Invoice for Advance Payment') : t8('Save and Invoice for Advance Payment')), + call => [ 'kivi.Order.save', 'save_and_invoice_for_advance_payment', $::instance_conf->get_order_warn_duplicate_parts ], + checks => [ 'kivi.Order.check_save_active_periodic_invoices', + @req_trans_cost_art, @req_cusordnumber, + ], + disabled => $has_final_invoice ? t8('This order has already a final invoice.') + : undef, + only_if => (any { $self->type eq $_ } (sales_order_type())), + ], + action => [ + t8('Save and Final Invoice'), + call => [ 'kivi.Order.save', 'save_and_final_invoice', $::instance_conf->get_order_warn_duplicate_parts ], + checks => [ 'kivi.Order.check_save_active_periodic_invoices', + @req_trans_cost_art, @req_cusordnumber, + ], + disabled => $has_final_invoice ? t8('This order has already a final invoice.') + : undef, + only_if => (any { $self->type eq $_ } (sales_order_type())) && $has_invoice_for_advance_payment, + ], action => [ t8('Save and AP Transaction'), call => [ 'kivi.Order.save', 'save_and_ap_transaction', $::instance_conf->get_order_warn_duplicate_parts ],