use SL::Helper::PrintOptions;
use SL::Helper::ShippedQty;
use SL::Helper::UserPreferences::PositionsScrollbar;
+use SL::Helper::UserPreferences::UpdatePositions;
use SL::Controller::Helper::GetModels;
use Rose::Object::MakeMethods::Generic
(
scalar => [ qw(item_ids_to_delete) ],
- 'scalar --get_set_init' => [ qw(order valid_types type cv p multi_items_models all_price_factors search_cvpartnumber) ],
+ 'scalar --get_set_init' => [ qw(order valid_types type cv p multi_items_models all_price_factors search_cvpartnumber show_update_button) ],
);
# print the order
#
# This is called if "print" is pressed in the print dialog.
-# If PDF creation was requested and succeeded, the pdf is stored in a session
-# file and the filename is stored as session value with an unique key. A
-# javascript function with this key is then called. This function calls the
-# download action below (action_download_pdf), which offers the file for
-# download.
+# If PDF creation was requested and succeeded, the pdf is offered for download
+# via send_file (which uses ajax in this case).
sub action_print {
my ($self) = @_;
if ($media eq 'screen') {
# screen/download
- my $sfile = SL::SessionFile::Random->new(mode => "w");
- $sfile->fh->print($pdf);
- $sfile->fh->close;
-
- my $key = join('_', Time::HiRes::gettimeofday(), int rand 1000000000000);
- $::auth->set_session_value("Order::print-${key}" => $sfile->file_name);
-
- $self->js
- ->run('kivi.Order.download_pdf', $pdf_filename, $key)
- ->flash('info', t8('The PDF has been created'));
+ $self->js->flash('info', t8('The PDF has been created'));
+ $self->send_file(
+ \$pdf,
+ type => SL::MIME->mime_type_from_ext($pdf_filename),
+ name => $pdf_filename,
+ js_no_render => 1,
+ );
} elsif ($media eq 'printer') {
# printer
$self->js->render;
}
-# offer pdf for download
-#
-# It needs to get the key for the session value to get the pdf file.
-sub action_download_pdf {
- my ($self) = @_;
-
- my $key = $::form->{key};
- my $tmp_filename = $::auth->get_session_value("Order::print-${key}");
- return $self->send_file(
- $tmp_filename,
- type => SL::MIME->mime_type_from_ext($::form->{pdf_filename}),
- name => $::form->{pdf_filename},
- );
-}
-
# open the email dialog
sub action_show_email_dialog {
my ($self) = @_;
my $item_id = join('_', 'new', Time::HiRes::gettimeofday(), int rand 1000000000000);
my $row_as_html = $self->p->render('order/tabs/_row',
- ITEM => $item,
- ID => $item_id,
- TYPE => $self->type,
- ALL_PRICE_FACTORS => $self->all_price_factors,
- SEARCH_CVPARTNUMBER => $self->search_cvpartnumber,
+ ITEM => $item,
+ ID => $item_id,
+ SELF => $self,
);
$self->js
$self->get_item_cvpartnumber($item);
my $item_id = join('_', 'new', Time::HiRes::gettimeofday(), int rand 1000000000000);
my $row_as_html = $self->p->render('order/tabs/_row',
- ITEM => $item,
- ID => $item_id,
- TYPE => $self->type,
- ALL_PRICE_FACTORS => $self->all_price_factors,
- SEARCH_CVPARTNUMBER => $self->search_cvpartnumber,
+ ITEM => $item,
+ ID => $item_id,
+ SELF => $self,
);
$self->js
->append('#row_table_id', $row_as_html);
$self->get_item_cvpartnumber($item);
my $item_id = join('_', 'new', Time::HiRes::gettimeofday(), int rand 1000000000000);
my $row_as_html = $self->p->render('order/tabs/_row',
- ITEM => $item,
- ID => $item_id,
- TYPE => $self->type,
- ALL_PRICE_FACTORS => $self->all_price_factors,
- SEARCH_CVPARTNUMBER => $self->search_cvpartnumber,
+ ITEM => $item,
+ ID => $item_id,
+ SELF => $self,
);
$self->js->append('#row_table_id', $row_as_html);
return $search_cvpartnumber;
}
+sub init_show_update_button {
+ my ($self) = @_;
+
+ !!SL::Helper::UserPreferences::UpdatePositions->new()->get_show_update_button();
+}
+
sub init_p {
SL::Presenter->get;
}