Revision 06ebdd6a
Von Moritz Bunkus vor fast 14 Jahren hinzugefügt
SL/Form.pm | ||
---|---|---|
49 | 49 |
use SL::Auth::DB; |
50 | 50 |
use SL::Auth::LDAP; |
51 | 51 |
use SL::AM; |
52 |
use SL::DB; |
|
53 | 52 |
use SL::Common; |
53 |
use SL::CVar; |
|
54 |
use SL::DB; |
|
54 | 55 |
use SL::DBUtils; |
56 |
use SL::DO; |
|
57 |
use SL::IS; |
|
55 | 58 |
use SL::Mailer; |
56 | 59 |
use SL::Menu; |
60 |
use SL::OE; |
|
57 | 61 |
use SL::Template; |
58 | 62 |
use SL::User; |
59 | 63 |
use Template; |
60 | 64 |
use URI; |
61 | 65 |
use List::Util qw(first max min sum); |
62 |
use List::MoreUtils qw(any apply); |
|
66 |
use List::MoreUtils qw(all any apply);
|
|
63 | 67 |
|
64 | 68 |
use strict; |
65 | 69 |
|
... | ... | |
3507 | 3511 |
$main::lxdebug->leave_sub(); |
3508 | 3512 |
} |
3509 | 3513 |
|
3514 |
sub prepare_for_printing { |
|
3515 |
my ($self) = @_; |
|
3516 |
|
|
3517 |
$self->{templates} ||= $::myconfig{templates}; |
|
3518 |
$self->{formname} ||= $self->{type}; |
|
3519 |
$self->{media} ||= 'email'; |
|
3520 |
|
|
3521 |
die "'media' other than 'email' or 'file' is not supported yet" unless $self->{media} =~ m/^(?:email|file)$/; |
|
3522 |
|
|
3523 |
# set shipto from billto unless set |
|
3524 |
my $has_shipto = any { $self->{"shipto$_"} } qw(name street zipcode city country contact); |
|
3525 |
if (!$has_shipto && ($self->{type} =~ m/^(?:purchase_order|request_quotation)$/)) { |
|
3526 |
$self->{shiptoname} = $::myconfig{company}; |
|
3527 |
$self->{shiptostreet} = $::myconfig{address}; |
|
3528 |
} |
|
3529 |
|
|
3530 |
my $language = $self->{language} ? '_' . $self->{language} : ''; |
|
3531 |
|
|
3532 |
my ($language_tc, $output_numberformat, $output_dateformat, $output_longdates); |
|
3533 |
if ($self->{language_id}) { |
|
3534 |
($language_tc, $output_numberformat, $output_dateformat, $output_longdates) = AM->get_language_details(\%::myconfig, $self, $self->{language_id}); |
|
3535 |
} else { |
|
3536 |
$output_dateformat = $::myconfig{dateformat}; |
|
3537 |
$output_numberformat = $::myconfig{numberformat}; |
|
3538 |
$output_longdates = 1; |
|
3539 |
} |
|
3540 |
|
|
3541 |
if ($self->{type} =~ /_delivery_order$/) { |
|
3542 |
DO->order_details(); |
|
3543 |
} elsif ($self->{type} =~ /sales_order|sales_quotation|request_quotation|purchase_order/) { |
|
3544 |
OE->order_details(\%::myconfig, $self); |
|
3545 |
} else { |
|
3546 |
IS->invoice_details(\%::myconfig, $self, $::locale); |
|
3547 |
} |
|
3548 |
|
|
3549 |
# Chose extension & set source file name |
|
3550 |
my $extension = 'html'; |
|
3551 |
if ($self->{format} eq 'postscript') { |
|
3552 |
$self->{postscript} = 1; |
|
3553 |
$extension = 'tex'; |
|
3554 |
} elsif ($self->{"format"} =~ /pdf/) { |
|
3555 |
$self->{pdf} = 1; |
|
3556 |
$extension = $self->{'format'} =~ m/opendocument/i ? 'odt' : 'tex'; |
|
3557 |
} elsif ($self->{"format"} =~ /opendocument/) { |
|
3558 |
$self->{opendocument} = 1; |
|
3559 |
$extension = 'odt'; |
|
3560 |
} elsif ($self->{"format"} =~ /excel/) { |
|
3561 |
$self->{excel} = 1; |
|
3562 |
$extension = 'xls'; |
|
3563 |
} |
|
3564 |
|
|
3565 |
my $email_extension = '_email' if -f "$::myconfig{templates}/$self->{formname}_email$self->{language}.${extension}"; |
|
3566 |
$self->{IN} = "$self->{formname}${email_extension}$self->{language}.${extension}"; |
|
3567 |
|
|
3568 |
# Format dates. |
|
3569 |
$self->format_dates($output_dateformat, $output_longdates, |
|
3570 |
qw(invdate orddate quodate pldate duedate reqdate transdate shippingdate deliverydate validitydate paymentdate datepaid |
|
3571 |
transdate_oe deliverydate_oe employee_startdate employee_enddate), |
|
3572 |
grep({ /^(?:datepaid|transdate_oe|reqdate|deliverydate|deliverydate_oe|transdate)_\d+$/ } keys(%{$self}))); |
|
3573 |
|
|
3574 |
$self->reformat_numbers($output_numberformat, 2, |
|
3575 |
qw(invtotal ordtotal quototal subtotal linetotal listprice sellprice netprice discount tax taxbase total paid), |
|
3576 |
grep({ /^(?:linetotal|listprice|sellprice|netprice|taxbase|discount|paid|subtotal|total|tax)_\d+$/ } keys(%{$self}))); |
|
3577 |
|
|
3578 |
$self->reformat_numbers($output_numberformat, undef, qw(qty price_factor), grep({ /^qty_\d+$/} keys(%{$self}))); |
|
3579 |
|
|
3580 |
my ($cvar_date_fields, $cvar_number_fields) = CVar->get_field_format_list('module' => 'CT', 'prefix' => 'vc_'); |
|
3581 |
|
|
3582 |
if (scalar @{ $cvar_date_fields }) { |
|
3583 |
$self->format_dates($output_dateformat, $output_longdates, @{ $cvar_date_fields }); |
|
3584 |
} |
|
3585 |
|
|
3586 |
while (my ($precision, $field_list) = each %{ $cvar_number_fields }) { |
|
3587 |
$self->reformat_numbers($output_numberformat, $precision, @{ $field_list }); |
|
3588 |
} |
|
3589 |
|
|
3590 |
return $self; |
|
3591 |
} |
|
3592 |
|
|
3510 | 3593 |
sub format_dates { |
3511 | 3594 |
my ($self, $dateformat, $longformat, @indices) = @_; |
3512 | 3595 |
|
Auch abrufbar als: Unified diff
Vorbereiten von $form für $form->parse_template, wenn von RDBO-Objekt mit flatten_to_form konvertiert wurde
Conflicts: