use SL::DB;
use SL::DBConnect;
use SL::DBUtils;
+use SL::DB::AdditionalBillingAddress;
use SL::DB::Customer;
use SL::DB::Default;
use SL::DB::PaymentTerm;
my $session_cookie_value = $main::auth->get_session_id();
if ($session_cookie_value) {
- $session_cookie = $cgi->cookie('-name' => $main::auth->get_session_cookie_name(),
- '-value' => $session_cookie_value,
- '-path' => $uri->path,
- '-expire' => '+' . ($::lx_office_conf{authentication}->{session_timeout} // 60) . 'm',
- '-secure' => $::request->is_https);
+ $session_cookie = $cgi->cookie('-name' => $main::auth->get_session_cookie_name(),
+ '-value' => $session_cookie_value,
+ '-path' => $uri->path,
+ '-expires' => '+' . $::auth->{session_timeout} . 'm',
+ '-secure' => $::request->is_https);
}
}
push @header, "<style type='text/css'>\@page { size:landscape; }</style> " if $self->{landscape};
push @header, "<link rel='shortcut icon' href='$self->{favicon}' type='image/x-icon'>" if -f $self->{favicon};
push @header, map { qq|<script type="text/javascript" src="${_}${auto_reload_resources_param}"></script>| } $layout->javascripts;
+ push @header, '<meta name="viewport" content="width=device-width, initial-scale=1">';
push @header, $self->{javascript} if $self->{javascript};
push @header, map { $_->show_javascript } @{ $self->{AJAX} || [] };
}
$language = "de" unless ($language);
- if (-f "templates/webpages/${file}.html") {
- $file = "templates/webpages/${file}.html";
+ my $webpages_path = $::request->layout->webpages_path;
+
+ if (-f "${webpages_path}/${file}.html") {
+ $file = "${webpages_path}/${file}.html";
} elsif (ref $file eq 'SCALAR') {
# file is a scalarref, use inline mode
SL::Helper::Number::_format_number($amount, $places, %$myconfig, dash => $dash);
}
-sub format_amount_units {
- $main::lxdebug->enter_sub();
-
- my $self = shift;
- my %params = @_;
-
- my $myconfig = \%main::myconfig;
- my $amount = $params{amount} * 1;
- my $places = $params{places};
- my $part_unit_name = $params{part_unit};
- my $amount_unit_name = $params{amount_unit};
- my $conv_units = $params{conv_units};
- my $max_places = $params{max_places};
-
- if (!$part_unit_name) {
- $main::lxdebug->leave_sub();
- return '';
- }
-
- my $all_units = AM->retrieve_all_units;
-
- if (('' eq ref $conv_units) && ($conv_units =~ /convertible/)) {
- $conv_units = AM->convertible_units($all_units, $part_unit_name, $conv_units eq 'convertible_not_smaller');
- }
-
- if (!scalar @{ $conv_units }) {
- my $result = $self->format_amount($myconfig, $amount, $places, undef, $max_places) . " " . $part_unit_name;
- $main::lxdebug->leave_sub();
- return $result;
- }
-
- my $part_unit = $all_units->{$part_unit_name};
- my $conv_unit = ($amount_unit_name && ($amount_unit_name ne $part_unit_name)) ? $all_units->{$amount_unit_name} : $part_unit;
-
- $amount *= $conv_unit->{factor};
-
- my @values;
- my $num;
-
- foreach my $unit (@$conv_units) {
- my $last = $unit->{name} eq $part_unit->{name};
- if (!$last) {
- $num = int($amount / $unit->{factor});
- $amount -= $num * $unit->{factor};
- }
-
- if ($last ? $amount : $num) {
- push @values, { "unit" => $unit->{name},
- "amount" => $last ? $amount / $unit->{factor} : $num,
- "places" => $last ? $places : 0 };
- }
-
- last if $last;
- }
-
- if (!@values) {
- push @values, { "unit" => $part_unit_name,
- "amount" => 0,
- "places" => 0 };
- }
-
- my $result = join " ", map { $self->format_amount($myconfig, $_->{amount}, $_->{places}, undef, $max_places), $_->{unit} } @values;
-
- $main::lxdebug->leave_sub();
-
- return $result;
-}
-
sub format_string {
$main::lxdebug->enter_sub(2);
}
}
- if (!$self->{preview} && $self->doc_storage_enabled)
+ if (!$self->{preview} && $self->{attachment_type} !~ m{^dunning} && $self->doc_storage_enabled)
{
$self->{attachment_filename} ||= $self->generate_attachment_filename;
$self->store_pdf($self);
}
}
- if ( !$self->{preview} && $ext_for_format eq 'pdf' && $self->doc_storage_enabled) {
+ if ( !$self->{preview} && $ext_for_format eq 'pdf' && $self->{attachment_type} !~ m{^dunning} && $self->doc_storage_enabled) {
$self->{attachment_filename} ||= $self->generate_attachment_filename;
my $file_obj = $self->store_pdf($self);
$self->{print_file_id} = $file_obj->id if $file_obj;
map { $mail->{$_} = $self->{$_} }
qw(cc subject message format);
+ if ($self->{cc_employee}) {
+ my ($user, $my_emp_cc);
+ $user = SL::DB::Manager::AuthUser->find_by(login => $self->{cc_employee});
+ $my_emp_cc = $user->get_config_value('email') if ref $user eq 'SL::DB::AuthUser';
+ $mail->{cc} .= ", " if $mail->{cc};
+ $mail->{cc} .= $my_emp_cc if $my_emp_cc;
+ }
+
$mail->{bcc} = $self->get_bcc_defaults($myconfig, $self->{bcc});
$mail->{to} = $self->{EMAIL_RECIPIENT} ? $self->{EMAIL_RECIPIENT} : $self->{email};
$mail->{from} = qq|"$myconfig->{name}" <$myconfig->{email}>|;
bin_list => $main::locale->text('Bin List'),
credit_note => $main::locale->text('Credit Note'),
invoice => $main::locale->text('Invoice'),
+ invoice_copy => $main::locale->text('Invoice Copy'),
pick_list => $main::locale->text('Pick List'),
proforma => $main::locale->text('Proforma Invoice'),
purchase_order => $main::locale->text('Purchase Order'),
$query =
qq|SELECT
a.cp_id, a.invnumber, a.transdate, a.${table}_id, a.datepaid, a.deliverydate,
- a.duedate, a.ordnumber, a.taxincluded, (SELECT cu.name FROM currencies cu WHERE cu.id=a.currency_id) AS currency, a.notes,
+ a.duedate, a.tax_point, a.ordnumber, a.taxincluded, (SELECT cu.name FROM currencies cu WHERE cu.id=a.currency_id) AS currency, a.notes,
a.mtime, a.itime,
a.intnotes, a.department_id, a.amount AS oldinvtotal,
a.paid AS oldtotalpaid, a.employee_id, a.gldate, a.type,
# $main::locale->text('ELSE')
# $main::locale->text('SAVED FOR DUNNING')
# $main::locale->text('DUNNING STARTED')
+# $main::locale->text('PREVIEWED')
# $main::locale->text('PRINTED')
# $main::locale->text('MAILED')
# $main::locale->text('SCREENED')
# $main::locale->text('CANCELED')
# $main::locale->text('IMPORT')
+# $main::locale->text('UNDO TRANSFER')
# $main::locale->text('UNIMPORT')
# $main::locale->text('invoice')
# $main::locale->text('proforma')
IS->invoice_details(\%::myconfig, $self, $::locale);
}
+ $self->set_addition_billing_address_print_variables;
+
# Chose extension & set source file name
my $extension = 'html';
if ($self->{format} eq 'postscript') {
# Format dates.
$self->format_dates($output_dateformat, $output_longdates,
- qw(invdate orddate quodate pldate duedate reqdate transdate shippingdate deliverydate validitydate paymentdate datepaid
+ qw(invdate orddate quodate pldate duedate reqdate transdate tax_point shippingdate deliverydate validitydate paymentdate datepaid
transdate_oe deliverydate_oe employee_startdate employee_enddate),
grep({ /^(?:datepaid|transdate_oe|reqdate|deliverydate|deliverydate_oe|transdate)_\d+$/ } keys(%{$self})));
today => DateTime->today,
};
+ if ($defaults->print_interpolate_variables_in_positions) {
+ $self->substitute_placeholders_in_template_arrays({ field => 'description', type => 'text' }, { field => 'longdescription', type => 'html' });
+ }
+
+ return $self;
+}
+
+sub set_addition_billing_address_print_variables {
+ my ($self) = @_;
+
+ return if !$self->{billing_address_id};
+
+ my $address = SL::DB::Manager::AdditionalBillingAddress->find_by(id => $self->{billing_address_id});
+ return if !$address;
+
+ $self->{"billing_address_${_}"} = $address->$_ for map { $_->name } @{ $address->meta->columns };
+}
+
+sub substitute_placeholders_in_template_arrays {
+ my ($self, @fields) = @_;
+
+ foreach my $spec (@fields) {
+ $spec = { field => $spec, type => 'text' } if !ref($spec);
+ my $field = $spec->{field};
+
+ next unless exists $self->{TEMPLATE_ARRAYS} && exists $self->{TEMPLATE_ARRAYS}->{$field};
+
+ my $tag_start = $spec->{type} eq 'html' ? '<%' : '<%';
+ my $tag_end = $spec->{type} eq 'html' ? '%>' : '%>';
+ my $formatter = $spec->{type} eq 'html' ? sub { $::locale->quote_special_chars('html', $_[0] // '') } : sub { $_[0] };
+
+ $self->{TEMPLATE_ARRAYS}->{$field} = [
+ apply { s{${tag_start}(.+?)${tag_end}}{ $formatter->($self->{$1}) }eg }
+ @{ $self->{TEMPLATE_ARRAYS}->{$field} }
+ ];
+ }
+
return $self;
}