use parent qw(SL::Controller::Base);
use SL::Helper::Flash qw(flash_later);
-use SL::Presenter;
+use SL::Presenter::Tag qw(select_tag);
use SL::Locale::String qw(t8);
use SL::SessionFile::Random;
use SL::PriceSource;
__PACKAGE__->run_before('_check_auth');
__PACKAGE__->run_before('_recalc',
- only => [ qw(save save_and_delivery_order print create_pdf send_email) ]);
+ only => [ qw(save save_and_delivery_order save_and_invoice print create_pdf send_email) ]);
__PACKAGE__->run_before('_get_unalterable_data',
- only => [ qw(save save_and_delivery_order print create_pdf send_email) ]);
+ only => [ qw(save save_and_delivery_order save_and_invoice print create_pdf send_email) ]);
#
# actions
}
}
if ($self->order->ordnumber && $::instance_conf->get_doc_storage) {
- SL::File->store( object_id => $self->order->id,
+ eval {
+ SL::File->save(object_id => $self->order->id,
object_type => $self->type,
mime_type => 'application/pdf',
source => 'created',
file_type => 'document',
file_name => $pdf_filename,
file_contents => $pdf);
+ 1;
+ } or do {
+ $self->js->flash('error', t8('Storing PDF in storage backend failed: #1', $@));
+ }
}
$self->js->render;
}
$self->redirect_to(@redirect_params);
}
+# save the order and redirect to the frontend subroutine for a new
+# invoice
+sub action_save_and_invoice {
+ my ($self) = @_;
+
+ my $errors = $self->_save();
+
+ if (scalar @{ $errors }) {
+ $self->js->flash('error', $_) foreach @{ $errors };
+ return $self->js->render();
+ }
+ flash_later('info', $::locale->text('The order has been saved'));
+
+ my @redirect_params = (
+ controller => 'oe.pl',
+ action => 'oe_invoice_from_order',
+ id => $self->order->id,
+ );
+
+ $self->redirect_to(@redirect_params);
+}
+
# set form elements in respect to a changed customer or vendor
#
# This action is called on an change of the customer/vendor picker.
$self->order->taxincluded(defined($self->order->$cv_method->taxincluded_checked)
? $self->order->$cv_method->taxincluded_checked
: $::myconfig{taxincluded_checked});
+ $self->js->val('#order_salesman_id', $self->order->$cv_method->salesman_id);
}
$self->order->payment_id($self->order->$cv_method->payment_id);
# set discount to 100% if item isn't supposed to be charged, overwriting any customer discount
$item->discount(1) unless $assortment_item->charge;
- push @items, $assortment_item;
+ push @items, $item;
}
}
}
sub build_contact_select {
my ($self) = @_;
- $self->p->select_tag('order.cp_id', [ $self->order->{$self->cv}->contacts ],
- value_key => 'cp_id',
- title_key => 'full_name_dep',
- default => $self->order->cp_id,
- with_empty => 1,
- style => 'width: 300px',
+ select_tag('order.cp_id', [ $self->order->{$self->cv}->contacts ],
+ value_key => 'cp_id',
+ title_key => 'full_name_dep',
+ default => $self->order->cp_id,
+ with_empty => 1,
+ style => 'width: 300px',
);
}
sub build_shipto_select {
my ($self) = @_;
- $self->p->select_tag('order.shipto_id', [ $self->order->{$self->cv}->shipto ],
- value_key => 'shipto_id',
- title_key => 'displayable_id',
- default => $self->order->shipto_id,
- with_empty => 1,
- style => 'width: 300px',
+ select_tag('order.shipto_id', [ $self->order->{$self->cv}->shipto ],
+ value_key => 'shipto_id',
+ title_key => 'displayable_id',
+ default => $self->order->shipto_id,
+ with_empty => 1,
+ style => 'width: 300px',
);
}
type => $self->type,
number => $self->order->ordnumber,
);
- my $webdav_path = $webdav->webdav_path;
my @all_objects = $webdav->get_all_objects;
@{ $self->{template_args}->{WEBDAV} } = map { { name => $_->filename,
type => t8('File'),
action => [
t8('Save and Delivery Order'),
call => [ 'kivi.Order.save_and_delivery_order', $::instance_conf->get_order_warn_duplicate_parts ],
- accesskey => 'enter',
+ ],
+ action => [
+ t8('Save and Invoice'),
+ call => [ 'kivi.Order.save_and_invoice', $::instance_conf->get_order_warn_duplicate_parts ],
],
], # end of combobox "Save"
t8('E-mail'),
call => [ 'kivi.Order.email' ],
],
+ action => [
+ t8('Download attachments of all parts'),
+ call => [ 'kivi.File.downloadOrderitemsFiles', $::form->{type}, $::form->{id} ],
+ disabled => !$self->order->id ? t8('This object has not been saved yet.') : undef,
+ only_if => $::instance_conf->get_doc_storage,
+ ],
], # end of combobox "Export"
action => [
=item * credit limit
-=item * more workflows (save as new / invoice)
+=item * more workflows (save as new, quotation, purchase order)
=item * price sources: little symbols showing better price / better discount
=item * access rights
-=item * preset salesman from customer
-
=item * display weights
=item * history
Customer discount is not displayed as a valid discount in price source popup
(this might be a bug in price sources)
+(I cannot reproduce this (Bernd))
+
=item *
No indication that <shift>-up/down expands/collapses second row.
A warning when leaving the page without saveing unchanged inputs.
+=item *
+
+Workflows for delivery order and invoice are in the menu "Save", because the
+order is saved before opening the new document form. Nevertheless perhaps these
+workflow buttons should be put under "Workflows".
+
+
=back
=head1 AUTHOR