X-Git-Url: http://wagnertech.de/git?a=blobdiff_plain;ds=sidebyside;f=bin%2Fmozilla%2Foe.pl;h=eb1697ea38ec3ec082710fdce7f44bc18cd2f564;hb=b2f45e7ebfee8fd1cf79632baccad61d6814fd8c;hp=5b8275c64bb4f2f675c6255bb3e5dd214382528b;hpb=47916a374217afc8d84bd147f0fada5086970bae;p=kivitendo-erp.git
diff --git a/bin/mozilla/oe.pl b/bin/mozilla/oe.pl
index 5b8275c64..eb1697ea3 100644
--- a/bin/mozilla/oe.pl
+++ b/bin/mozilla/oe.pl
@@ -1,4 +1,4 @@
-# #=====================================================================
+#=====================================================================
# LX-Office ERP
# Copyright (C) 2004
# Based on SQL-Ledger Version 2.1.9
@@ -30,15 +30,21 @@
# Order entry module
# Quotation module
#======================================================================
-use Data::Dumper;
+use POSIX qw(strftime);
+
+use SL::DO;
+use SL::FU;
use SL::OE;
use SL::IR;
use SL::IS;
use SL::PE;
+use SL::ReportGenerator;
+use List::Util qw(max reduce sum);
require "bin/mozilla/io.pl";
require "bin/mozilla/arap.pl";
+require "bin/mozilla/reportgenerator.pl";
1;
@@ -55,9 +61,25 @@ require "bin/mozilla/arap.pl";
# $locale->text('Workflow request_quotation');
# $locale->text('Workflow sales_quotation');
+my $oe_access_map = {
+ 'sales_order' => 'sales_order_edit',
+ 'purchase_order' => 'purchase_order_edit',
+ 'request_quotation' => 'request_quotation_edit',
+ 'sales_quotation' => 'sales_quotation_edit',
+};
+
+sub check_oe_access {
+ my $right = $oe_access_map->{$form->{type}};
+ $right ||= 'DOES_NOT_EXIST';
+
+ $auth->assert($right);
+}
+
sub set_headings {
$lxdebug->enter_sub();
+ check_oe_access();
+
my ($action) = @_;
if ($form->{type} eq 'purchase_order') {
@@ -95,10 +117,12 @@ sub set_headings {
sub add {
$lxdebug->enter_sub();
+ check_oe_access();
+
set_headings("add");
$form->{callback} =
- "$form->{script}?action=add&type=$form->{type}&vc=$form->{vc}&login=$form->{login}&password=$form->{password}"
+ "$form->{script}?action=add&type=$form->{type}&vc=$form->{vc}"
unless $form->{callback};
&order_links;
@@ -110,6 +134,9 @@ sub add {
sub edit {
$lxdebug->enter_sub();
+
+ check_oe_access();
+
# show history button
$form->{javascript} = qq||;
#/show hhistory button
@@ -119,7 +146,7 @@ sub edit {
set_headings("edit");
# editing without stuff to edit? try adding it first
- if ($form->{rowcount}) {
+ if ($form->{rowcount} && !$form->{print_and_save}) {
map { $id++ if $form->{"multi_id_$_"} } (1 .. $form->{rowcount});
if (!$id) {
@@ -145,11 +172,20 @@ sub edit {
set_headings("edit");
&order_links;
+
+ $form->{rowcount} = 0;
+ foreach $ref (@{ $form->{form_details} }) {
+ $form->{rowcount}++;
+ map { $form->{"${_}_$form->{rowcount}"} = $ref->{$_} } keys %{$ref};
+ }
+
&prepare_order;
+
if ($form->{print_and_save}) {
$form->{language_id} = $language_id;
$form->{printer_id} = $printer_id;
}
+
&display_form;
$lxdebug->leave_sub();
@@ -157,163 +193,66 @@ sub edit {
sub order_links {
$lxdebug->enter_sub();
+
+ check_oe_access();
+
# get customer/vendor
- $form->all_vc(\%myconfig, $form->{vc},
- ($form->{vc} eq 'customer') ? "AR" : "AP");
+ $form->all_vc(\%myconfig, $form->{vc}, ($form->{vc} eq 'customer') ? "AR" : "AP");
# retrieve order/quotation
- $form->{webdav} = $webdav;
- # set jscalendar
- $form->{jscalendar} = $jscalendar;
+ $form->{webdav} = $webdav;
+ $form->{jsscript} = 1;
my $editing = $form->{id};
OE->retrieve(\%myconfig, \%$form);
- if ($form->{payment_id}) {
- $payment_id = $form->{payment_id};
- }
- if ($form->{language_id}) {
- $language_id = $form->{language_id};
- }
- if ($form->{taxzone_id}) {
- $taxzone_id = $form->{taxzone_id};
- }
-
- $salesman_id = $form->{salesman_id} if ($editing);
-
-
# if multiple rowcounts (== collective order) then check if the
# there were more than one customer (in that case OE::retrieve removes
# the content from the field)
- if ( $form->{rowcount}
- && $form->{type} eq 'sales_order'
- && defined $form->{customer}
- && $form->{customer} eq '') {
-
- # $main::lxdebug->message(0, "Detected Edit order with concurrent customers");
- $form->error(
- $locale->text(
- 'Collective Orders only work for orders from one customer!')
- );
- }
-
- $taxincluded = $form->{taxincluded};
- $form->{shipto} = 1 if $form->{id};
+ $form->error($locale->text('Collective Orders only work for orders from one customer!'))
+ if $form->{rowcount} && $form->{type} eq 'sales_order'
+ && defined $form->{customer} && $form->{customer} eq '';
- if ($form->{"all_$form->{vc}"}) {
- unless ($form->{"$form->{vc}_id"}) {
- $form->{"$form->{vc}_id"} = $form->{"all_$form->{vc}"}->[0]->{id};
- }
- }
+ $form->{"$form->{vc}_id"} ||= $form->{"all_$form->{vc}"}->[0]->{id} if $form->{"all_$form->{vc}"};
- $cp_id = $form->{cp_id};
- $intnotes = $form->{intnotes};
+ $form->backup_vars(qw(payment_id language_id taxzone_id salesman_id taxincluded cp_id intnotes));
+ $form->{shipto} = 1 if $form->{id};
# get customer / vendor
- if ($form->{type} =~ /(purchase_order|request_quotation)/) {
- IR->get_vendor(\%myconfig, \%$form);
-
- #quote all_vendor Bug 133
- foreach $ref (@{ $form->{all_vendor} }) {
- $ref->{name} = $form->quote($ref->{name});
- }
+ IR->get_vendor(\%myconfig, \%$form) if $form->{type} =~ /(purchase_order|request_quotation)/;
+ IS->get_customer(\%myconfig, \%$form) if $form->{type} =~ /sales_(order|quotation)/;
- }
- if ($form->{type} =~ /sales_(order|quotation)/) {
- IS->get_customer(\%myconfig, \%$form);
-
- #quote all_vendor Bug 133
- foreach $ref (@{ $form->{all_customer} }) {
- $ref->{name} = $form->quote($ref->{name});
- }
-
- }
- $form->{cp_id} = $cp_id;
-
- if ($payment_id) {
- $form->{payment_id} = $payment_id;
- }
- if ($language_id) {
- $form->{language_id} = $language_id;
- }
- if ($taxzone_id) {
- $form->{taxzone_id} = $taxzone_id;
- }
- $form->{intnotes} = $intnotes if $intnotes;
- ($form->{ $form->{vc} }) = split /--/, $form->{ $form->{vc} };
- $form->{"old$form->{vc}"} =
- qq|$form->{$form->{vc}}--$form->{"$form->{vc}_id"}|;
+ $form->restore_vars(qw(payment_id language_id taxzone_id intnotes cp_id));
+ $form->restore_vars(qw(taxincluded)) if $form->{id};
+ $form->restore_vars(qw(salesman_id)) if $editing;
+ $form->{forex} = $form->{exchangerate};
+ $form->{employee} = "$form->{employee}--$form->{employee_id}";
- # build the popup menus
+ # build vendor/customer drop down comatibility... don't ask
if (@{ $form->{"all_$form->{vc}"} }) {
- $form->{ $form->{vc} } =
- qq|$form->{$form->{vc}}--$form->{"$form->{vc}_id"}|;
- map { $form->{"select$form->{vc}"} .=
-"\n" }
- (@{ $form->{"all_$form->{vc}"} });
- }
-
- $form->{taxincluded} = $taxincluded if ($form->{id});
-
- # departments
- if (@{ $form->{all_departments} }) {
- $form->{selectdepartment} = "\n"
- } (@{ $form->{all_departments} });
+ $form->{"select$form->{vc}"} = 1;
+ $form->{$form->{vc}} = qq|$form->{$form->{vc}}--$form->{"$form->{vc}_id"}|;
}
- $form->{employee} = "$form->{employee}--$form->{employee_id}";
-
- # forex
- $form->{forex} = $form->{exchangerate};
-
- $form->{salesman_id} = $salesman_id if ($editing);
+ $form->{"old$form->{vc}"} = $form->{$form->{vc}};
+ $form->{"old$form->{vc}"} .= qq|--$form->{"$form->{vc}_id"}| unless ($form->{"old$form->{vc}"} =~ m/--\d+$/);
$lxdebug->leave_sub();
}
sub prepare_order {
$lxdebug->enter_sub();
- $form->{formname} = $form->{type} unless $form->{formname};
- my $i = 0;
- foreach $ref (@{ $form->{form_details} }) {
- $form->{rowcount} = ++$i;
+ check_oe_access();
- map { $form->{"${_}_$i"} = $ref->{$_} } keys %{$ref};
- }
- for my $i (1 .. $form->{rowcount}) {
- if ($form->{id}) {
- $form->{"discount_$i"} =
- $form->format_amount(\%myconfig, $form->{"discount_$i"} * 100);
- } else {
- $form->{"discount_$i"} =
- $form->format_amount(\%myconfig, $form->{"discount_$i"});
- }
- ($dec) = ($form->{"sellprice_$i"} =~ /\.(\d+)/);
- $dec = length $dec;
- $decimalplaces = ($dec > 2) ? $dec : 2;
+ $form->{formname} ||= $form->{type};
- # copy reqdate from deliverydate for invoice -> order conversion
- $form->{"reqdate_$i"} = $form->{"deliverydate_$i"}
- unless $form->{"reqdate_$i"};
-
- $form->{"sellprice_$i"} =
- $form->format_amount(\%myconfig, $form->{"sellprice_$i"},
- $decimalplaces);
-
- (my $dec_qty) = ($form->{"qty_$i"} =~ /\.(\d+)/);
- $dec_qty = length $dec_qty;
- $form->{"qty_$i"} =
- $form->format_amount(\%myconfig, $form->{"qty_$i"}, $dec_qty);
-
- map { $form->{"${_}_$i"} =~ s/\"/"/g }
- qw(partnumber description unit);
+ for my $i (1 .. $form->{rowcount}) {
+ $form->{"reqdate_$i"} ||= $form->{"deliverydate_$i"};
+ $form->{"discount_$i"} = $form->format_amount(\%myconfig, $form->{"discount_$i"} * ($form->{id} ? 100 : 1));
+ $form->{"sellprice_$i"} = $form->format_amount(\%myconfig, $form->{"sellprice_$i"});
+ $form->{"qty_$i"} = $form->format_amount(\%myconfig, $form->{"qty_$i"});
}
$lxdebug->leave_sub();
@@ -321,916 +260,229 @@ sub prepare_order {
sub form_header {
$lxdebug->enter_sub();
+ my @custom_hiddens;
- my $checkedclosed = $form->{"closed"} ? "checked" : "";
- my $checkeddelivered = $form->{"delivered"} ? "checked" : "";
-
- map { $form->{$_} =~ s/\"/"/g }
- qw(ordnumber quonumber shippingpoint shipvia notes intnotes shiptoname
- shiptostreet shiptozipcode shiptocity shiptocountry shiptocontact
- shiptophone shiptofax shiptodepartment_1 shiptodepartment_2);
+ check_oe_access();
- # use JavaScript Calendar or not
- $form->{jsscript} = $form->{jscalendar};
- $jsscript = "";
+ # Container for template variables. Unfortunately this has to be visible in form_footer too, so not my.
+ our %TMPL_VAR = ();
- if ($form->{jsscript}) {
-
- # with JavaScript Calendar
- $button1 = qq|
-
- text('button') . qq|> |
- |;
- $button2 = qq|
-
- text('button') . qq|> |
- |;
-
- #write Trigger
- $jsscript =
- Form->write_trigger(\%myconfig, "2", "transdate", "BL", "trigger1",
- "reqdate", "BL", "trigger2");
+ $form->{defaultcurrency} = $form->get_default_currency(\%myconfig);
- } else {
+ $form->{employee_id} = $form->{old_employee_id} if $form->{old_employee_id};
+ $form->{salesman_id} = $form->{old_salesman_id} if $form->{old_salesman_id};
- # without JavaScript Calendar
- $button1 = qq|
- | |;
- $button2 = qq|
- | |;
- }
+ # use JavaScript Calendar or not
+ $form->{jsscript} = 1;
+ # openclosed checkboxes
my @tmp;
+ push @tmp, sprintf qq||,
+ $form->{"delivered"} ? "checked" : "", $locale->text('Delivered') if $form->{"type"} =~ /_order$/;
+ push @tmp, sprintf qq||,
+ $form->{"closed"} ? "checked" : "", $locale->text('Closed') if $form->{id};
+ $TMPL_VAR{openclosed} = sprintf qq|%s |
\n|, 2 * scalar @tmp, join "\n", @tmp if @tmp;
- if (($form->{"type"} eq "sales_order") ||
- ($form->{"type"} eq "purchase_order")) {
- push(@tmp, qq|
-
- |);
- }
-
- if ($form->{id}) {
- push(@tmp, qq|
-
- |);
- }
-
- if (@tmp) {
- $openclosed .= qq|
-
- | . join("\n", @tmp) . qq|
- |
-
-|;
- }
-
- # set option selected
- foreach $item ($form->{vc}, currency, department, employee, ($form->{vc} eq "customer" ? customer : vendor)) {
- $form->{"select$item"} =~ s/ selected//;
- $form->{"select$item"} =~
- s/option>\Q$form->{$item}\E/option selected>$form->{$item}/;
- }
-
- #quote select[customer|vendor] Bug 133
- $form->{"select$form->{vc}"} = $form->quote($form->{"select$form->{vc}"});
-
- #substitute \n and \r to \s (bug 543)
- $form->{"select$form->{vc}"} =~ s/[\n\r]/ /g;
-
- my @old_project_ids = ($form->{"globalproject_id"});
- map({ push(@old_project_ids, $form->{"project_id_$_"})
- if ($form->{"project_id_$_"}); } (1..$form->{"rowcount"}));
+ # project ids
+ my @old_project_ids = ($form->{"globalproject_id"}, grep { $_ } map { $form->{"project_id_$_"} } 1..$form->{"rowcount"});
my $vc = $form->{vc} eq "customer" ? "customers" : "vendors";
- $form->get_lists("contacts" => "ALL_CONTACTS",
- "shipto" => "ALL_SHIPTO",
- "projects" => { "key" => "ALL_PROJECTS",
- "all" => 0,
- "old_id" => \@old_project_ids },
- "employees" => "ALL_SALESMEN",
- "taxzones" => "ALL_TAXZONES",
- "payments" => "ALL_PAYMENTS",
- "currencies" => "ALL_CURRENCIES",
- $vc => "ALL_" . uc($vc));
-
- my %labels;
- my @values = (undef);
- foreach my $item (@{ $form->{"ALL_CONTACTS"} }) {
- push(@values, $item->{"cp_id"});
- $labels{$item->{"cp_id"}} = $item->{"cp_name"} .
- ($item->{"cp_abteilung"} ? " ($item->{cp_abteilung})" : "");
- }
-
- my $contact;
- if (scalar @values > 1) {
- $contact = qq|
-
- | . $locale->text('Contact Person') . qq| |
- | .
- NTI($cgi->popup_menu('-name' => 'cp_id', '-values' => \@values,
- '-labels' => \%labels, '-default' => $form->{"cp_id"}))
- . qq|
- |
-
|;
- }
-
- %labels = ();
- @values = ();
-
- foreach my $item (@{ $form->{($form->{vc} eq "customer" ? "ALL_CUSTOMERS" : "ALL_VENDORS")}}) {
- push(@values, $item->{name}.qq|--|.$item->{"id"});
- $labels{$item->{"id"}} = $item->{name}.qq|--|.$item->{"id"};
- }
-
- $vc = qq|
- {vc}_id"}) . qq|">
- {vc}"}) . qq|">
- | . $locale->text(ucfirst($form->{vc})) . qq| |
- | .
- (($myconfig{vclimit} <= scalar(@values))
- ? qq|{vc}"}) . qq|" name="$form->{vc}">|
- : (NTI($cgi->popup_menu('-name' => "$form->{vc}", '-default' => $form->{"old$form->{vc}"},
- '-onChange' => 'document.getElementById(\'update_button\').click();',
- '-values' => \@values, '-labels' => \%labels)))) . qq|
- | {vc}"}) . qq|">|;
-
- %labels = ();
- @values = ("");
- foreach my $item (@{ $form->{"ALL_PAYMENTS"} }) {
- push(@values, $item->{"id"});
- $labels{$item->{"id"}} = $item->{"description"};
- }
+ $form->get_lists("contacts" => "ALL_CONTACTS",
+ "shipto" => "ALL_SHIPTO",
+ "projects" => { "key" => "ALL_PROJECTS",
+ "all" => 0,
+ "old_id" => \@old_project_ids },
+ "employees" => "ALL_EMPLOYEES",
+ "salesmen" => "ALL_SALESMEN",
+ "taxzones" => "ALL_TAXZONES",
+ "payments" => "ALL_PAYMENTS",
+ "currencies" => "ALL_CURRENCIES",
+ "departments" => "ALL_DEPARTMENTS",
+ $vc => { key => "ALL_" . uc($vc),
+ limit => $myconfig{vclimit} + 1 },
+ "price_factors" => "ALL_PRICE_FACTORS");
+
+ # label subs
+ $TMPL_VAR{sales_employee_labels} = sub { $_[0]->{name} || $_[0]->{login} };
+ $TMPL_VAR{shipto_labels} = sub { join "; ", grep { $_ } map { $_[0]->{"shipto${_}" } } qw(name department_1 street city) };
+ $TMPL_VAR{contact_labels} = sub { join(', ', $_[0]->{"cp_name"}, $_[0]->{"cp_givenname"}) . ($_[0]->{cp_abteilung} ? " ($_[0]->{cp_abteilung})" : "") };
+ $TMPL_VAR{department_labels} = sub { "$_[0]->{description}--$_[0]->{id}" };
+
+ # vendor/customer
+ $TMPL_VAR{vc_keys} = sub { "$_[0]->{name}--$_[0]->{id}" };
+ $TMPL_VAR{vclimit} = $myconfig{vclimit};
+ $TMPL_VAR{vc_select} = "customer_or_vendor_selection_window('$form->{vc}', '', @{[ $form->{vc} eq 'vendor' ? 1 : 0 ]}, 0)";
+ push @custom_hiddens, "$form->{vc}_id";
+ push @custom_hiddens, "old$form->{vc}";
+ push @custom_hiddens, "select$form->{vc}";
+
+ # currencies and exchangerate
+ @values = map { $_ } @{ $form->{ALL_CURRENCIES} };
+ %labels = map { $_ => $_ } @{ $form->{ALL_CURRENCIES} };
+ $form->{currency} = $form->{defaultcurrency} unless $form->{currency};
+ $TMPL_VAR{show_exchangerate} = $form->{currency} ne $form->{defaultcurrency};
+ $TMPL_VAR{currencies} = NTI($cgi->popup_menu('-name' => 'currency', '-default' => $form->{"currency"},
+ '-values' => \@values, '-labels' => \%labels)) if scalar @values;
+ push @custom_hiddens, "forex";
+ push @custom_hiddens, "exchangerate" if $form->{forex};
+
+ # credit remaining
+ $creditwarning = (($form->{creditlimit} != 0) && ($form->{creditremaining} < 0) && !$form->{update}) ? 1 : 0;
+ $TMPL_VAR{is_credit_remaining_negativ} = ($form->{creditremaining} =~ /-/) ? "0" : "1";
- $payments = qq|
- | . $locale->text('Payment Terms') . qq| |
- | .
- NTI($cgi->popup_menu('-name' => 'payment_id', '-values' => \@values,
- '-labels' => \%labels, '-default' => $form->{payment_id}))
- . qq| | |;
-
- %labels = ();
- @values = ("");
- foreach my $item (@{ $form->{"ALL_SHIPTO"} }) {
- push(@values, $item->{"shipto_id"});
- $labels{$item->{"shipto_id"}} =
- $item->{"shiptoname"} . " " . $item->{"shiptodepartment_1"};
- }
+ # business
+ $TMPL_VAR{business_label} = ($form->{vc} eq "customer" ? $locale->text('Customer type') : $locale->text('Vendor type'));
- my $shipto;
- if (scalar @values > 1) {
- $shipto = qq|
-
- | . $locale->text('Shipping Address') . qq| |
- | .
- NTI($cgi->popup_menu('-name' => 'shipto_id', '-values' => \@values,
- '-labels' => \%labels, '-default' => $form->{"shipto_id"}))
- . qq| | |;
- }
+ push @custom_hiddens, "customer_klass" if $form->{vc} eq 'customer';
- %labels = ();
- @values = ("");
- foreach my $item (@{ $form->{"ALL_PROJECTS"} }) {
- push(@values, $item->{"id"});
- $labels{$item->{"id"}} = $item->{"projectnumber"};
- }
- my $globalprojectnumber =
- NTI($cgi->popup_menu('-name' => 'globalproject_id', '-values' => \@values,
- '-labels' => \%labels,
- '-default' => $form->{"globalproject_id"}));
-
- $salesman = "";
- if ($form->{type} =~ /^sales_/) {
- %labels = ();
- @values = ("");
- foreach my $item (@{ $form->{ALL_SALESMEN} }) {
- push(@values, $item->{id});
- $labels{$item->{id}} = $item->{name} ne "" ? $item->{name} : $item->{login};
- }
-
- $salesman =
- qq|
- | . $locale->text('Salesman') . qq| |
- | .
- NTI($cgi->popup_menu('-name' => 'salesman_id', '-default' => $form->{salesman_id},
- '-values' => \@values, '-labels' => \%labels))
- . qq| |
-
|;
- }
-
- %labels = ();
- @values = ();
- foreach my $item (@{ $form->{"ALL_SALESMEN"} }) {
- push(@values, $item->{"id"});
- $labels{$item->{"id"}} = $item->{"name"};
- }
-
- my $employees = qq|
-
- | . $locale->text('Employee') . qq| |
- | .
- NTI($cgi->popup_menu('-name' => 'employee', '-default' => $form->{"employee"},
- '-values' => \@values, '-labels' => \%labels)) . qq|
- |
-
|;
-
- %labels = ();
- @values = ();
- foreach my $item (@{ $form->{"ALL_TAXZONES"} }) {
- push(@values, $item->{"id"});
- $labels{$item->{"id"}} = $item->{"description"};
- }
-
- $taxzone = qq|
-
- | . $locale->text('Steuersatz') . qq| |
- | .
- NTI($cgi->popup_menu('-name' => 'taxzone_id', '-default' => $form->{"taxzone_id"},
- '-values' => \@values, '-labels' => \%labels)) . qq|
- |
-
|;
-
- %labels = ();
- @values = ();
- my $i = 0;
- foreach my $item (@{ $form->{"ALL_CURRENCIES"} }) {
- push(@values, $item);
- $labels{$item} = $item;
- }
-
- $form->{currency} = $form->{defaultcurrency} unless $form->{currency};
- my $currencies;
- if (scalar @values) {
- $currencies = qq|
-
- | . $locale->text('Currency') . qq| |
- | .
- NTI($cgi->popup_menu('-name' => 'currency', '-default' => $form->{"currency"},
- '-values' => \@values, '-labels' => \%labels)) . qq|
- |
-
|;
- }
-
- $form->{exchangerate} =
- $form->format_amount(\%myconfig, $form->{exchangerate});
-
- if (($form->{creditlimit} != 0) && ($form->{creditremaining} < 0) && !$form->{update}) {
- $creditwarning = 1;
- } else {
- $creditwarning = 0;
- }
-
- $form->{creditlimit} =
- $form->format_amount(\%myconfig, $form->{creditlimit}, 0, "0");
- $form->{creditremaining} =
- $form->format_amount(\%myconfig, $form->{creditremaining}, 0, "0");
-
- $exchangerate = qq|
-{forex}>
-|;
-
- if ($form->{currency} ne $form->{defaultcurrency}) {
- if ($form->{forex}) {
- $exchangerate .=
- qq||
- . $locale->text('Exchangerate')
- . qq| | $form->{exchangerate} |
- {exchangerate}>
-|;
- } else {
- $exchangerate .=
- qq||
- . $locale->text('Exchangerate')
- . qq| | {exchangerate}> | |;
- }
- }
-
- if ($form->{business}) {
- $business = qq|
-
- | . $locale->text('Business') . qq| |
- $form->{business} |
- | . $locale->text('Trade Discount') . qq| |
- |
- . $form->format_amount(\%myconfig, $form->{tradediscount} * 100)
- . qq| % |
-
-|;
- }
-
- if ($form->{max_dunning_level}) {
- $dunning = qq|
-
-
-
-
- | . $locale->text('Max. Dunning Level') . qq|: |
- $form->{max_dunning_level} |
- | . $locale->text('Dunning Amount') . qq|: |
- |
- . $form->format_amount(\%myconfig, $form->{dunning_amount},2)
- . qq| |
-
-
- |
-
-|;
- }
-
- if ($form->{type} !~ /_quotation$/) {
- $ordnumber = qq|
-
- | . $locale->text('Order Number') . qq| |
- |
-
-
- |
- . $locale->text('Quotation Number') . qq| |
- |
-
-
- |
- . $locale->text('Customer Order Number') . qq| |
- |
-
-
- | . $locale->text('Order Date') . qq| |
- $button1
-
-
-
- | . $locale->text('Required by') . qq| |
- $button2
-
-|;
+ $credittext = $locale->text('Credit Limit exceeded!!!');
- $n = ($form->{creditremaining} =~ /-/) ? "0" : "1";
+ my $follow_up_vc = $form->{ $form->{vc} eq 'customer' ? 'customer' : 'vendor' };
+ $follow_up_vc =~ s/--.*?//;
+ $TMPL_VAR{follow_up_trans_info} = ($form->{type} =~ /_quotation$/ ? $form->{quonumber} : $form->{ordnumber}) . " ($follow_up_vc)";
- $creditremaining = qq|
-
- |
-
-
-
- | . $locale->text('Credit Limit') . qq| |
- $form->{creditlimit} |
- |
- | . $locale->text('Remaining') . qq| |
- $form->{creditremaining} |
-
-
- |
- $shipto
-
-|;
- } else {
- $reqlabel =
- ($form->{type} eq 'sales_quotation')
- ? $locale->text('Valid until')
- : $locale->text('Required by');
- if ($form->{type} eq 'sales_quotation') {
- $ordnumber = qq|
-
- |
- . $locale->text('Quotation Number') . qq| |
- |
-
-
-|;
- } else {
- $ordnumber = qq|
-
- | . $locale->text('RFQ Number') . qq| |
- |
-
-
-|;
+ if ($form->{id}) {
+ my $follow_ups = FU->follow_ups('trans_id' => $form->{id});
+ if (scalar @{ $follow_ups }) {
+ $TMPL_VAR{num_follow_ups} = scalar @{ $follow_ups };
+ $TMPL_VAR{num_due_follow_ups} = sum map { $_->{due} * 1 } @{ $follow_ups };
}
-
- $ordnumber .= qq|
-
- | . $locale->text('Quotation Date') . qq| |
- $button1
-
-
- $reqlabel |
- $button2
-
-|;
- $creditremaining = qq|
- |
- $shipto
-
|;
}
- $department = qq|
-
- | . $locale->text('Department') . qq| |
-
-
- |
-
| if $form->{selectdepartment};
+ $onload = ($form->{resubmit} && ($form->{format} eq "html")) ? "window.open('about:blank','Beleg'); document.oe.target = 'Beleg';document.oe.submit()"
+ : ($form->{resubmit}) ? "document.oe.submit()"
+ : ($creditwarning) ? "alert('$credittext')"
+ : "focus()";
- if ($form->{type} eq 'sales_order') {
- if ($form->{selectemployee}) {
- $employee = qq|
- {customer_klass}>
- $employees
-|;
- }
- } else {
- $employee = qq|
- {customer_klass}>
- $employees
-|;
- }
- if ($form->{resubmit} && ($form->{format} eq "html")) {
- $onload =
- qq|window.open('about:blank','Beleg'); document.oe.target = 'Beleg';document.oe.submit()|;
- } elsif ($form->{resubmit}) {
- $onload = qq|document.oe.submit()|;
- } else {
- $onload = "focus()";
- }
-
- $credittext = $locale->text('Credit Limit exceeded!!!');
- if ($creditwarning) {
- $onload = qq|alert('$credittext')|;
- }
-
$onload .= qq|;setupDateFormat('|. $myconfig{dateformat} .qq|', '|. $locale->text("Falsches Datumsformat!") .qq|')|;
- $onload .= qq|;setupPoints('|. $myconfig{numberformat} .qq|', '|. $locale->text("wrongformat") .qq|')|;
-
- $form->{"javascript"} .= qq||;
- # show history button js
- $form->{javascript} .= qq||;
- #/show history button js
- $form->header;
-
- print qq|
-
-
-
-
-
-