X-Git-Url: http://wagnertech.de/git?a=blobdiff_plain;f=bin%2Fmozilla%2Foe.pl;h=cb55f0714f7fb776811dafe350bb61293ee8cdea;hb=29d636435456494e8dc702ccc1015452a71275d9;hp=ccc9ef1736b55ea58e54b32ee83a1bc22e906f16;hpb=168218647abacbfb5599be7beae82ae832cf2efb;p=kivitendo-erp.git
diff --git a/bin/mozilla/oe.pl b/bin/mozilla/oe.pl
index ccc9ef173..cb55f0714 100644
--- a/bin/mozilla/oe.pl
+++ b/bin/mozilla/oe.pl
@@ -30,15 +30,18 @@
# Order entry module
# Quotation module
#======================================================================
-use Data::Dumper;
+
+use POSIX qw(strftime);
use SL::OE;
use SL::IR;
use SL::IS;
use SL::PE;
+use SL::ReportGenerator;
require "bin/mozilla/io.pl";
require "bin/mozilla/arap.pl";
+require "bin/mozilla/reportgenerator.pl";
1;
@@ -119,7 +122,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) {
@@ -324,6 +327,23 @@ sub form_header {
my $checkedclosed = $form->{"closed"} ? "checked" : "";
my $checkeddelivered = $form->{"delivered"} ? "checked" : "";
+ if ($form->{old_employee_id}) {
+ $form->{employee_id} = $form->{old_employee_id};
+ }
+ if ($form->{old_salesman_id}) {
+ $form->{salesman_id} = $form->{old_salesman_id};
+ }
+
+ $form->{defaultcurrency} = $form->get_default_currency(\%myconfig);
+
+
+ if ($form->{old_employee_id}) {
+ $form->{employee_id} = $form->{old_employee_id};
+ }
+ if ($form->{old_salesman_id}) {
+ $form->{salesman_id} = $form->{old_salesman_id};
+ }
+
map { $form->{$_} =~ s/\"/"/g }
qw(ordnumber quonumber shippingpoint shipvia notes intnotes shiptoname
shiptostreet shiptozipcode shiptocity shiptocountry shiptocontact
@@ -428,8 +448,8 @@ sub form_header {
@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"};
+ push(@values, $item->{"name"}.qq|--|.$item->{"id"});
+ $labels{$item->{"name"}.qq|--|.$item->{"id"}} = $item->{name};
}
$vc = qq|
@@ -438,7 +458,7 @@ sub form_header {
| . $locale->text(ucfirst($form->{vc})) . qq| |
| .
(($myconfig{vclimit} <= scalar(@values))
- ? qq|{vc}"}) . qq|" name="$form->{vc}">|
+ ? 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, '-style' => 'width: 250px')))) . qq|
@@ -563,6 +583,10 @@ sub form_header {
$form->{exchangerate} =
$form->format_amount(\%myconfig, $form->{exchangerate});
+ if (!$form->{exchangerate}) {
+ $form->{exchangerate} = "";
+ }
+
if (($form->{creditlimit} != 0) && ($form->{creditremaining} < 0) && !$form->{update}) {
$creditwarning = 1;
} else {
@@ -986,9 +1010,31 @@ sub form_footer {
|
-
+ |
+
+|;
+
+ if ($form->{type} =~ /^sales_/) {
+ print qq|
+
+ | . $locale->text('Ertrag') . qq| |
+ | . $form->format_amount(\%myconfig, $form->{marge_total}, 2, 0) . qq| |
+
+
+ | . $locale->text('Ertrag prozentual') . qq| |
+ | . $form->format_amount(\%myconfig, $form->{marge_percent}, 2, 0) . qq| % |
+
+|;
+ }
+
+ print qq|
+
+
+
+ |
+
$taxincluded
-
+
$subtotal
$tax
@@ -1018,11 +1064,11 @@ sub form_footer {
Dateiname |
Webdavlink |
|;
- foreach $file (keys %{ $form->{WEBDAV} }) {
+ foreach $file (@{ $form->{WEBDAV} }) {
$webdav_list .= qq|
- $file |
- $form->{WEBDAV}{$file} |
+ $file->{name} |
+ $file->{type} |
|;
}
@@ -1086,12 +1132,10 @@ sub form_footer {
|;
}
- if (1) {
print qq|
|;
-}
if ($form->{type} =~ /sales_order$/) {
print qq|
@@ -1118,14 +1162,6 @@ sub form_footer {
. $locale->text('Order') . qq|">
|;
}
- } elsif ($form->{type} =~ /sales_order$/ && $form->{rowcount} && !$form->{proforma}) {
- print qq|
- Workflow $form->{heading}
-
-
-|;
}
$form->hide_form("saved_xyznumber");
@@ -1386,6 +1422,7 @@ sub search {
$form->get_lists("projects" => { "key" => "ALL_PROJECTS",
"all" => 1 },
+ "employees" => "ALL_EMPLOYEES",
$vc => "ALL_" . uc($vc));
my %labels = ();
@@ -1398,24 +1435,41 @@ sub search {
NTI($cgi->popup_menu('-name' => 'project_id', '-values' => \@values,
'-labels' => \%labels));
+ #employees
+ %labels = ();
+ @values = ("");
+ foreach my $item (@{ $form->{"ALL_EMPLOYEES"} }) {
+ push(@values, $item->{"id"});
+ $labels{$item->{"id"}} = $item->{"name"} ne "" ? $item->{"name"} : $item->{"login"};
+ }
+
+ my $employee_block = qq|
+
+ | . $locale->text('Employee') . qq| |
+ | .
+ NTI($cgi->popup_menu('-name' => 'employee_id',
+ '-values' => \@values,
+ '-labels' => \%labels)) . 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"};
+ $labels{$item->{name}.qq|--|.$item->{"id"}} = $item->{"name"};
}
my $vc_label = $form->{vc} eq "customer" ? $locale->text('Customer') : $locale->text('Vendor');
$vc =
$myconfig{vclimit} <= scalar(@values)
- ? qq|{vc}"}) . qq|" name="$form->{vc}">|
+ ? 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));
-
$form->header;
print qq|
@@ -1440,6 +1494,7 @@ sub search {
$ordlabel |
|
+ $employee_block
| . $locale->text('Transaction description') . qq| |
|
@@ -1476,11 +1531,10 @@ sub search {
. $locale->text('Required by') . qq|
- ucfirst($form->{vc}) |
+ $vc_label |
$employee |
|
. $locale->text('Ship via') . qq| |
- $employee |
|
@@ -1491,6 +1545,12 @@ sub search {
. $locale->text('Total') . qq| |
+ |
+ . $locale->text('Ertrag') . qq| |
+ |
+ . $locale->text('Ertrag prozentual') . qq| |
+
+
|
. $locale->text('Project Number') . qq| |
|
@@ -1529,368 +1589,261 @@ $jsscript
$lxdebug->leave_sub();
}
+sub create_subtotal_row {
+ $lxdebug->enter_sub();
+
+ my ($totals, $columns, $column_alignment, $subtotal_columns, $class) = @_;
+
+ my $row = { map { $_ => { 'data' => '', 'class' => $class, 'align' => $column_alignment->{$_}, } } @{ $columns } };
+
+ map { $row->{$_}->{data} = $form->format_amount(\%myconfig, $totals->{$_}, 2) } @{ $subtotal_columns };
+
+ $row->{tax}->{data} = $form->format_amount(\%myconfig, $totals->{amount} - $totals->{netamount}, 2);
+
+ map { $totals->{$_} = 0 } @{ $subtotal_columns };
+
+ $lxdebug->leave_sub();
+
+ return $row;
+}
+
sub orders {
$lxdebug->enter_sub();
$ordnumber = ($form->{type} =~ /_order$/) ? "ordnumber" : "quonumber";
- # construct href
- my @fields =
- qw(type vc login password transdatefrom transdateto
- open closed notdelivered delivered department
- transaction_description);
- push @fields, $form->{vc};
- $href = "$form->{script}?action=orders&"
- . join("&", map { "${_}=" . E($form->{$_}) } @fields)
- . "&${ordnumber}=" . E($form->{$ordnumber});
- $callback = $href;
-
- # split vendor / customer
- ($form->{ $form->{vc} }, $form->{"$form->{vc}_id"}) =
- split(/--/, $form->{ $form->{vc} });
+ ($form->{ $form->{vc} }, $form->{"${form->{vc}}_id"}) = split(/--/, $form->{ $form->{vc} });
+
+ $form->{sort} ||= 'transdate';
OE->transactions(\%myconfig, \%$form);
- @columns = (
+ $form->{rowcount} = scalar @{ $form->{OE} };
+
+ my @columns = (
"transdate", "reqdate",
- "id", "$ordnumber",
+ "id", $ordnumber,
"name", "netamount",
"tax", "amount",
"curr", "employee",
"shipvia", "globalprojectnumber",
"transaction_description", "open",
- "closed", "delivered"
+ "delivered", "marge_total", "marge_percent"
);
- $form->{l_open} = $form->{l_closed} = "Y"
- if ($form->{open} && $form->{closed});
-
- $form->{"l_delivered"} = "Y"
- if ($form->{"delivered"} && $form->{"notdelivered"});
-
- foreach $item (@columns) {
- if ($form->{"l_$item"} eq "Y") {
- push @column_index, $item;
-
- # add column to href and callback
- $callback .= "&l_$item=Y";
- $href .= "&l_$item=Y";
- }
- }
-
# only show checkboxes if gotten here via sales_order form.
- if ($form->{type} =~ /sales_order/) {
- unshift @column_index, "ids";
+ my $allow_multiple_orders = $form->{type} eq 'sales_order';
+ if ($allow_multiple_orders) {
+ unshift @columns, "ids";
}
- if ($form->{l_subtotal} eq 'Y') {
- $callback .= "&l_subtotal=Y";
- $href .= "&l_subtotal=Y";
- }
+ $form->{l_open} = $form->{l_closed} = "Y" if ($form->{open} && $form->{closed});
+ $form->{l_delivered} = "Y" if ($form->{delivered} && $form->{notdelivered});
+ my $attachment_basename;
if ($form->{vc} eq 'vendor') {
if ($form->{type} eq 'purchase_order') {
- $form->{title} = $locale->text('Purchase Orders');
+ $form->{title} = $locale->text('Purchase Orders');
+ $attachment_basename = $locale->text('purchase_order_list');
} else {
- $form->{title} = $locale->text('Request for Quotations');
+ $form->{title} = $locale->text('Request for Quotations');
+ $attachment_basename = $locale->text('rfq_list');
}
- $name = $locale->text('Vendor');
- $employee = $locale->text('Employee');
- }
- if ($form->{vc} eq 'customer') {
+
+ } else {
if ($form->{type} eq 'sales_order') {
- $form->{title} = $locale->text('Sales Orders');
+ $form->{title} = $locale->text('Sales Orders');
+ $attachment_basename = $locale->text('sales_order_list');
} else {
- $form->{title} = $locale->text('Quotations');
+ $form->{title} = $locale->text('Quotations');
+ $attachment_basename = $locale->text('quotation_list');
}
- $employee = $locale->text('Employee');
- $name = $locale->text('Customer');
- }
-
- $column_header{id} =
- qq| | |
- . $locale->text('ID')
- . qq| | |;
- $column_header{transdate} =
- qq||
- . $locale->text('Date')
- . qq| | |;
- $column_header{reqdate} =
- qq||
- . $locale->text('Required by')
- . qq| | |;
- $column_header{ordnumber} =
- qq||
- . $locale->text('Order')
- . qq| | |;
- $column_header{quonumber} =
- qq||
- . ($form->{"type"} eq "request_quotation" ?
- $locale->text('RFQ') :
- $locale->text('Quotation'))
- . qq| | |;
- $column_header{name} =
- qq|$name | |;
- $column_header{netamount} =
- qq|| . $locale->text('Amount') . qq| | |;
- $column_header{tax} =
- qq|| . $locale->text('Tax') . qq| | |;
- $column_header{amount} =
- qq|| . $locale->text('Total') . qq| | |;
- $column_header{curr} =
- qq|| . $locale->text('Curr') . qq| | |;
- $column_header{shipvia} =
- qq||
- . $locale->text('Ship via')
- . qq| | |;
- $column_header{globalprojectnumber} =
- qq|| . $locale->text('Project Number') . qq| | |;
- $column_header{open} =
- qq|| . $locale->text('O') . qq| | |;
- $column_header{closed} =
- qq|| . $locale->text('C') . qq| | |;
- $column_header{"delivered"} =
- qq|| . $locale->text("Delivered") . qq| | |;
-
- $column_header{employee} =
- qq|$employee | |;
- $column_header{transaction_description} =
- qq||
- . $locale->text("Transaction description") . qq| | |;
-
- $column_header{ids} = qq| | |;
-
- if ($form->{ $form->{vc} }) {
- $option = $locale->text(ucfirst $form->{vc});
- $option .= " : $form->{$form->{vc}}";
+ }
+
+ my $report = SL::ReportGenerator->new(\%myconfig, $form);
+
+ my @hidden_variables = map { "l_${_}" } @columns;
+ push @hidden_variables, "l_subtotal", $form->{vc}, qw(l_closed l_notdelivered open closed delivered notdelivered ordnumber quonumber
+ transaction_description transdatefrom transdateto type vc employee_id);
+
+ my $href = build_std_url('action=orders', grep { $form->{$_} } @hidden_variables);
+
+ my %column_defs = (
+ 'ids' => { 'text' => '', },
+ 'transdate' => { 'text' => $locale->text('Date'), },
+ 'reqdate' => { 'text' => $locale->text('Required by'), },
+ 'id' => { 'text' => $locale->text('ID'), },
+ 'ordnumber' => { 'text' => $locale->text('Order'), },
+ 'quonumber' => { 'text' => $form->{type} eq "request_quotation" ? $locale->text('RFQ') : $locale->text('Quotation'), },
+ 'name' => { 'text' => $form->{vc} eq 'customer' ? $locale->text('Customer') : $locale->text('Vendor'), },
+ 'netamount' => { 'text' => $locale->text('Amount'), },
+ 'tax' => { 'text' => $locale->text('Tax'), },
+ 'amount' => { 'text' => $locale->text('Total'), },
+ 'curr' => { 'text' => $locale->text('Curr'), },
+ 'employee' => { 'text' => $locale->text('Salesperson'), },
+ 'shipvia' => { 'text' => $locale->text('Ship via'), },
+ 'globalprojectnumber' => { 'text' => $locale->text('Project Number'), },
+ 'transaction_description' => { 'text' => $locale->text('Transaction description'), },
+ 'open' => { 'text' => $locale->text('Open'), },
+ 'delivered' => { 'text' => $locale->text('Delivered'), },
+ 'marge_total' => { 'text' => $locale->text('Ertrag'), },
+ 'marge_percent' => { 'text' => $locale->text('Ertrag prozentual'), }
+ );
+
+ foreach my $name (qw(id transdate reqdate quonumber ordnumber name employee shipvia)) {
+ $column_defs{$name}->{link} = $href . "&sort=$name";
+ }
+
+ my %column_alignment = map { $_ => 'right' } qw(netamount tax amount curr);
+
+ $form->{"l_type"} = "Y";
+ map { $column_defs{$_}->{visible} = $form->{"l_${_}"} ? 1 : 0 } @columns;
+ $column_defs{ids}->{visible} = $allow_multiple_orders ? 'HTML' : 0;
+
+ $report->set_columns(%column_defs);
+ $report->set_column_order(@columns);
+
+ $report->set_export_options('orders', @hidden_variables);
+
+ $report->set_sort_indicator($form->{sort}, 1);
+
+ my @options;
+ if ($form->{customer}) {
+ push @options, $locale->text('Customer') . " : $form->{customer}";
+ }
+ if ($form->{vendor}) {
+ push @options, $locale->text('Vendor') . " : $form->{vendor}";
}
if ($form->{department}) {
- $option .= "\n " if ($option);
($department) = split /--/, $form->{department};
- $option .= $locale->text('Department') . " : $department";
+ push @options, $locale->text('Department') . " : $department";
+ }
+ if ($form->{ordnumber}) {
+ push @options, $locale->text('Order Number') . " : $form->{ordnumber}";
+ }
+ if ($form->{notes}) {
+ push @options, $locale->text('Notes') . " : $form->{notes}";
+ }
+ if ($form->{transaction_description}) {
+ push @options, $locale->text('Transaction description') . " : $form->{transaction_description}";
}
if ($form->{transdatefrom}) {
- $option .= "\n "
- . $locale->text('From') . " "
- . $locale->date(\%myconfig, $form->{transdatefrom}, 1);
+ push @options, $locale->text('From') . " " . $locale->date(\%myconfig, $form->{transdatefrom}, 1);
}
if ($form->{transdateto}) {
- $option .= "\n "
- . $locale->text('Bis') . " "
- . $locale->date(\%myconfig, $form->{transdateto}, 1);
+ push @options, $locale->text('Bis') . " " . $locale->date(\%myconfig, $form->{transdateto}, 1);
}
if ($form->{open}) {
- $option .= "\n " if ($option);
- $option .= $locale->text('Open');
+ push @options, $locale->text('Open');
}
if ($form->{closed}) {
- $option .= "\n " if ($option);
- $option .= $locale->text('Closed');
+ push @options, $locale->text('Closed');
+ }
+ if ($form->{delivered}) {
+ push @options, $locale->text('Delivered');
+ }
+ if ($form->{notdelivered}) {
+ push @options, $locale->text('Not delivered');
}
- $form->header;
-
- print qq|
-
+ $report->set_options('top_info_text' => join("\n", @options),
+ 'raw_top_info_text' => $form->parse_html_template('oe/orders_top'),
+ 'raw_bottom_info_text' => $form->parse_html_template('oe/orders_bottom', { 'SHOW_CONTINUE_BUTTON' => $allow_multiple_orders }),
+ 'output_format' => 'HTML',
+ 'title' => $form->{title},
+ 'attachment_basename' => $attachment_basename . strftime('_%Y%m%d', localtime time),
+ );
+ $report->set_options_from_form();
-
+ $report->add_separator();
+ $report->add_data(create_subtotal_row(\%totals, \@columns, \%column_alignment, \@subtotal_columns, 'listtotal'));
-
-
-
-
- |