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 multi_items_models 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) ],
);
foreach my $item (@{$self->order->items_sorted}) {
$item->{new_fake_id} = join('_', 'new', Time::HiRes::gettimeofday(), int rand 1000000000000);
}
- # trigger rendering values for second row/longdescription as hidden,
- # because they are loaded only on demand. So we need to keep the values
- # from the source.
- $_->{render_second_row} = 1 for @{ $self->order->items_sorted };
- $_->{render_longdescription} = 1 for @{ $self->order->items_sorted };
+ # trigger rendering values for second row as hidden, because they
+ # are loaded only on demand. So we need to keep the values from
+ # the source.
+ $_->{render_second_row} = 1 for @{ $self->order->items_sorted };
}
$self->recalc();
my $formname = $::form->{print_options}->{formname};
my $copies = $::form->{print_options}->{copies};
my $groupitems = $::form->{print_options}->{groupitems};
+ my $printer_id = $::form->{print_options}->{printer_id};
# only pdf and opendocument by now
if (none { $format eq $_ } qw(pdf opendocument opendocument_pdf)) {
my @errors = generate_pdf($self->order, \$pdf, { format => $format,
formname => $formname,
language => $self->order->language,
+ printer_id => $printer_id,
groupitems => $groupitems });
if (scalar @errors) {
return $self->js->flash('error', t8('Conversion to PDF failed: #1', $errors[0]))->render;
format => $::form->{print_options}->{format},
formname => $::form->{print_options}->{formname},
language => $self->order->language,
+ printer_id => $::form->{print_options}->{printer_id},
groupitems => $::form->{print_options}->{groupitems}});
if (scalar @errors) {
return $self->js->flash('error', t8('Conversion to PDF failed: #1', $errors[0]))->render($self);
sub action_save_and_delivery_order {
my ($self) = @_;
- my $errors = $self->save();
-
- if (scalar @{ $errors }) {
- $self->js->flash('error', $_) foreach @{ $errors };
- return $self->js->render();
- }
-
- my $text = $self->type eq sales_order_type() ? $::locale->text('The order has been saved')
- : $self->type eq purchase_order_type() ? $::locale->text('The order has been saved')
- : $self->type eq sales_quotation_type() ? $::locale->text('The quotation has been saved')
- : $self->type eq request_quotation_type() ? $::locale->text('The rfq has been saved')
- : '';
- flash_later('info', $text);
-
- my @redirect_params = (
+ $self->save_and_redirect_to(
controller => 'oe.pl',
action => 'oe_delivery_order_from_order',
- id => $self->order->id,
);
-
- $self->redirect_to(@redirect_params);
}
# save the order and redirect to the frontend subroutine for a new
sub action_save_and_invoice {
my ($self) = @_;
- my $errors = $self->save();
-
- if (scalar @{ $errors }) {
- $self->js->flash('error', $_) foreach @{ $errors };
- return $self->js->render();
- }
-
- my $text = $self->type eq sales_order_type() ? $::locale->text('The order has been saved')
- : $self->type eq purchase_order_type() ? $::locale->text('The order has been saved')
- : $self->type eq sales_quotation_type() ? $::locale->text('The quotation has been saved')
- : $self->type eq request_quotation_type() ? $::locale->text('The rfq has been saved')
- : '';
- flash_later('info', $text);
-
- my @redirect_params = (
+ $self->save_and_redirect_to(
controller => 'oe.pl',
action => 'oe_invoice_from_order',
- id => $self->order->id,
);
+}
- $self->redirect_to(@redirect_params);
+# workflow from sales order to sales quotation
+sub action_sales_quotation {
+ $_[0]->workflow_sales_or_request_for_quotation();
+}
+
+# workflow from sales order to sales quotation
+sub action_request_for_quotation {
+ $_[0]->workflow_sales_or_request_for_quotation();
}
# workflow from sales quotation to sales order
sub action_save_and_ap_transaction {
my ($self) = @_;
- my $errors = $self->save();
-
- if (scalar @{ $errors }) {
- $self->js->flash('error', $_) foreach @{ $errors };
- return $self->js->render();
- }
-
- my $text = $self->type eq sales_order_type() ? $::locale->text('The order has been saved')
- : $self->type eq purchase_order_type() ? $::locale->text('The order has been saved')
- : $self->type eq sales_quotation_type() ? $::locale->text('The quotation has been saved')
- : $self->type eq request_quotation_type() ? $::locale->text('The rfq has been saved')
- : '';
- flash_later('info', $text);
-
- my @redirect_params = (
+ $self->save_and_redirect_to(
controller => 'ap.pl',
action => 'add_from_purchase_order',
- id => $self->order->id,
);
-
- $self->redirect_to(@redirect_params);
}
# set form elements in respect to a changed customer or vendor
$self->js->render();
}
-# open the dialog for entering multiple items at once
-sub action_show_multi_items_dialog {
- $_[0]->render('order/tabs/_multi_items_dialog', { layout => 0 },
- all_partsgroups => SL::DB::Manager::PartsGroup->get_all);
-}
-
-# update the filter results in the multi item dialog
-sub action_multi_items_update_result {
- my $max_count = 100;
-
- $::form->{multi_items}->{filter}->{obsolete} = 0;
-
- my $count = $_[0]->multi_items_models->count;
-
- if ($count == 0) {
- my $text = SL::Presenter::EscapedText->new(text => $::locale->text('No results.'));
- $_[0]->render($text, { layout => 0 });
- } elsif ($count > $max_count) {
- my $text = SL::Presenter::EscapedText->new(text => $::locale->text('Too many results (#1 from #2).', $count, $max_count));
- $_[0]->render($text, { layout => 0 });
- } else {
- my $multi_items = $_[0]->multi_items_models->get;
- $_[0]->render('order/tabs/_multi_items_result', { layout => 0 },
- multi_items => $multi_items);
- }
-}
-
# add item rows for multiple items at once
sub action_add_multi_items {
my ($self) = @_;
- my @form_attr = grep { $_->{qty_as_number} } @{ $::form->{add_multi_items} };
+ my @form_attr = grep { $_->{qty_as_number} } @{ $::form->{add_items} };
return $self->js->render() unless scalar @form_attr;
my @items;
}
$self->js
- ->run('kivi.Order.close_multi_items_dialog')
+ ->run('kivi.Part.close_picker_dialogs')
->run('kivi.Order.init_row_handlers')
->run('kivi.Order.renumber_positions')
->focus('#add_item_parts_id_name');
$self->render_price_dialog($item);
}
-# get the longdescription for an item if the dialog to enter/change the
-# longdescription was opened and the longdescription is empty
-#
-# If this item is new, get the longdescription from Part.
-# Otherwise get it from OrderItem.
-sub action_get_item_longdescription {
- my $longdescription;
-
- if ($::form->{item_id}) {
- $longdescription = SL::DB::OrderItem->new(id => $::form->{item_id})->load->longdescription;
- } elsif ($::form->{parts_id}) {
- $longdescription = get_part_texts($::form->{parts_id}, $::form->{language_id})->{longdescription};
- }
- $_[0]->render(\ $longdescription, { type => 'text' });
-}
-
# load the second row for one or more items
#
# This action gets the html code for all items second rows by rendering a template for
$_[0]->make_order;
}
-# model used to filter/display the parts in the multi-items dialog
-sub init_multi_items_models {
- SL::Controller::Helper::GetModels->new(
- controller => $_[0],
- model => 'Part',
- with_objects => [ qw(unit_obj) ],
- disable_plugin => 'paginated',
- source => $::form->{multi_items},
- sorted => {
- _default => {
- by => 'partnumber',
- dir => 1,
- },
- partnumber => t8('Partnumber'),
- description => t8('Description')}
- );
-}
-
sub init_all_price_factors {
SL::DB::Manager::PriceFactor->get_all;
}
return $errors;
}
+sub workflow_sales_or_request_for_quotation {
+ my ($self) = @_;
+
+ # always save
+ my $errors = $self->save();
+
+ if (scalar @{ $errors }) {
+ $self->js->flash('error', $_) for @{ $errors };
+ return $self->js->render();
+ }
+
+ my $destination_type = $::form->{type} eq sales_order_type() ? sales_quotation_type() : request_quotation_type();
+
+ $self->order(SL::DB::Order->new_from($self->order, destination_type => $destination_type));
+ $self->{converted_from_oe_id} = delete $::form->{id};
+
+ # set item ids to new fake id, to identify them as new items
+ foreach my $item (@{$self->order->items_sorted}) {
+ $item->{new_fake_id} = join('_', 'new', Time::HiRes::gettimeofday(), int rand 1000000000000);
+ }
+
+ # change form type
+ $::form->{type} = $destination_type;
+ $self->type($self->init_type);
+ $self->cv ($self->init_cv);
+ $self->check_auth;
+
+ $self->recalc();
+ $self->get_unalterable_data();
+ $self->pre_render();
+
+ # trigger rendering values for second row as hidden, because they
+ # are loaded only on demand. So we need to keep the values from the
+ # source.
+ $_->{render_second_row} = 1 for @{ $self->order->items_sorted };
+
+ $self->render(
+ 'order/form',
+ title => $self->get_title_for('edit'),
+ %{$self->{template_args}}
+ );
+}
+
sub workflow_sales_or_purchase_order {
my ($self) = @_;
$self->get_unalterable_data();
$self->pre_render();
- # trigger rendering values for second row/longdescription as hidden,
- # because they are loaded only on demand. So we need to keep the values
- # from the source.
- $_->{render_second_row} = 1 for @{ $self->order->items_sorted };
- $_->{render_longdescription} = 1 for @{ $self->order->items_sorted };
+ # trigger rendering values for second row as hidden, because they
+ # are loaded only on demand. So we need to keep the values from the
+ # source.
+ $_->{render_second_row} = 1 for @{ $self->order->items_sorted };
$self->render(
'order/form',
action => [
t8('Workflow'),
],
+ action => [
+ t8('Save and Quotation'),
+ submit => [ '#order_form', { action => "Order/sales_quotation" } ],
+ only_if => (any { $self->type eq $_ } (sales_order_type())),
+ ],
+ action => [
+ t8('Save and RFQ'),
+ submit => [ '#order_form', { action => "Order/request_for_quotation" } ],
+ only_if => (any { $self->type eq $_ } (purchase_order_type())),
+ ],
action => [
t8('Save and Sales Order'),
submit => [ '#order_form', { action => "Order/sales_order" } ],
$print_form->{format} = $params->{format} || 'pdf';
$print_form->{media} = $params->{media} || 'file';
$print_form->{groupitems} = $params->{groupitems};
+ $print_form->{printer_id} = $params->{printer_id};
$print_form->{media} = 'file' if $print_form->{media} eq 'screen';
$order->language($params->{language});
extension => $template_ext,
email => $print_form->{media} eq 'email',
language => $params->{language},
- printer_id => $print_form->{printer_id}, # todo
+ printer_id => $print_form->{printer_id},
);
if (!defined $template_file) {
: '';
}
+sub save_and_redirect_to {
+ my ($self, %params) = @_;
+
+ my $errors = $self->save();
+
+ if (scalar @{ $errors }) {
+ $self->js->flash('error', $_) foreach @{ $errors };
+ return $self->js->render();
+ }
+
+ my $text = $self->type eq sales_order_type() ? $::locale->text('The order has been saved')
+ : $self->type eq purchase_order_type() ? $::locale->text('The order has been saved')
+ : $self->type eq sales_quotation_type() ? $::locale->text('The quotation has been saved')
+ : $self->type eq request_quotation_type() ? $::locale->text('The rfq has been saved')
+ : '';
+ flash_later('info', $text);
+
+ $self->redirect_to(%params, id => $self->order->id);
+}
+
1;
__END__
Displaying tax information
-=item * C<template/webpages/order/tabs/_multi_items_dialog.html>
-
-Dialog for entering more than one item at once
-
-=item * C<template/webpages/order/tabs/_multi_items_result.html>
-
-Results for the filter in the multi items dialog
-
=item * C<template/webpages/order/tabs/_price_sources_dialog.html>
Dialog for selecting price and discount sources
=item * testing
-=item * credit limit
-
-=item * more workflows (quotation, rfq)
-
=item * price sources: little symbols showing better price / better discount
=item * select units in input row?
=item * check for direct delivery (workflow sales order -> purchase order)
-=item * language / part translations
-
=item * access rights
=item * display weights
This behavior was implemented intentionally. But we can discuss, which behavior
should be implemented.
-=item *
-
-C<show_multi_items_dialog> does not use the currently inserted string for
-filtering.
-
=back
=head1 To discuss / Nice to have
=item *
-Possibility to change longdescription in input row?
-
-=item *
-
Possibility to select PriceSources in input row?
=item *