@@ -747,24 +792,15 @@ sub form_header {
- $vclabel |
- $vc |
- {vc}_id value=$form->{"$form->{vc}_id"}>
- {vc}"}">
- |
- . $locale->text('Contact Person') . qq| |
- $contact |
-
+ $vc
+ $contact
$creditremaining
$business
$dunning
$taxzone
$department
- | . $locale->text('Currency') . qq| |
- |
-
- {defaultcurrency}>
+ $currencies
$exchangerate
@@ -774,7 +810,11 @@ sub form_header {
| . $locale->text('Ship via') . qq| |
|
- |;
+
+
+ | . $locale->text('Transaction description') . qq| |
+ |
+ |;
#
#
#
@@ -801,6 +841,7 @@ print qq|
$openclosed
$employee
+ $salesmen
$ordnumber
| . $locale->text('Project Number') . qq| |
@@ -891,7 +932,8 @@ sub form_footer {
$tax .= qq|
- $form->{"${item}_description"} |
+ $form->{"${item}_description"} |
+ . $form->{"${item}_rate"} * 100 .qq|% |
$form->{"${item}_total"} |
|;
@@ -930,7 +972,8 @@ sub form_footer {
$tax .= qq|
- Enthaltene $form->{"${item}_description"} |
+ Enthaltene $form->{"${item}_description"} |
+ . $form->{"${item}_rate"} * 100 .qq|% |
$form->{"${item}_total"} |
@@ -962,14 +1005,36 @@ sub form_footer {
$notes |
$intnotes |
- | . $locale->text('Payment Terms') . qq| |
- |
-
+ |
+ $payments
+
+
|
-
+ |
+
+|;
+
+ 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
@@ -999,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} |
|;
}
@@ -1017,14 +1082,12 @@ sub form_footer {
print $webdav_list;
}
- print qq|
-{jscalendar}>
-|;
+
print qq|
|;
- &print_options;
+ print_options();
print qq|
|
@@ -1048,6 +1111,12 @@ sub form_footer {
if (($form->{id})) {
print qq|
+
+
| . $locale->text("Workflow $form->{type}") . qq|
@@ -1063,12 +1132,10 @@ sub form_footer {
|;
}
- if (1) {
print qq|
|;
-}
if ($form->{type} =~ /sales_order$/) {
print qq|
@@ -1095,36 +1162,19 @@ 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");
+
print qq|
{rowcount}>
-{path}>
{login}>
{password}>
-|;
-# button for saving history
-print qq|
- {id}
- . qq|); name=history id=history value=|
- . $locale->text('history')
- . qq|>|;
-# /button for saving history
-
-qq|
+
@@ -1141,9 +1191,17 @@ sub update {
map { $form->{$_} = $form->parse_amount(\%myconfig, $form->{$_}) }
qw(exchangerate creditlimit creditremaining);
$form->{update} = 1;
-
+
+ if($form->{payment_id}) {
+ $payment_id = $form->{payment_id};
+ }
+
&check_name($form->{vc});
-
+
+ if($form->{payment_id} eq "") {
+ $form->{payment_id} = $payment_id;
+ }
+
$buysell = 'buy';
$buysell = 'sell' if ($form->{vc} eq 'vendor');
$form->{exchangerate} = $exchangerate
@@ -1295,7 +1353,7 @@ sub search {
$form->{vc} = 'customer';
$ordlabel = $locale->text('Order Number');
$ordnumber = 'ordnumber';
- $employee = $locale->text('Salesperson');
+ $employee = $locale->text('Employee');
}
if ($form->{type} eq 'sales_quotation') {
@@ -1310,27 +1368,13 @@ sub search {
$form->all_vc(\%myconfig, $form->{vc},
($form->{vc} eq 'customer') ? "AR" : "AP");
- map { $vc .= "\n";
map {
$form->{selectdepartment} .=
- "$_->{description}--$_->{id}\n"
+ "$_->{description}--$_->{id}\n"
} (@{ $form->{all_departments} });
}
@@ -1341,10 +1385,6 @@ sub search {
| if $form->{selectdepartment};
- $openclosed = qq|
-
-|;
-
my $delivered;
if (($form->{"type"} eq "sales_order") ||
($form->{"type"} eq "purchase_order")) {
@@ -1359,37 +1399,31 @@ sub search {
}
# use JavaScript Calendar or not
- $form->{jsscript} = $jscalendar;
+ $form->{jsscript} = 1;
$jsscript = "";
- if ($form->{jsscript}) {
-
- # with JavaScript Calendar
- $button1 = qq|
-
- text('button') . qq|> |
- |;
- $button2 = qq|
-
- text('button') . qq|> |
- |;
-
- #write Trigger
- $jsscript =
- Form->write_trigger(\%myconfig, "2", "transdatefrom", "BR", "trigger3",
- "transdateto", "BL", "trigger4");
- } else {
- # without JavaScript Calendar
- $button1 = qq|
- | |;
- $button2 = qq|
- | |;
- }
+ $button1 = qq|
+
+ text('button') . qq|> |
+ |;
+ $button2 = qq|
+
+ text('button') . qq|> |
+ |;
+
+ #write Trigger
+ $jsscript =
+ Form->write_trigger(\%myconfig, "2", "transdatefrom", "BR", "trigger3",
+ "transdateto", "BL", "trigger4");
+
+ my $vc = $form->{vc} eq "customer" ? "customers" : "vendors";
$form->get_lists("projects" => { "key" => "ALL_PROJECTS",
- "all" => 1 });
+ "all" => 1 },
+ "employees" => "ALL_EMPLOYEES",
+ $vc => "ALL_" . uc($vc));
my %labels = ();
my @values = ("");
@@ -1401,6 +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->{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}">|
+ : 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|
@@ -1417,7 +1486,7 @@ sub search {
- $vclabel |
+ $vc_label |
$vc |
$department
@@ -1425,6 +1494,11 @@ sub search {
$ordlabel |
|
+ $employee_block
+
+ | . $locale->text('Transaction description') . qq| |
+ |
+
| . $locale->text("Project Number") . qq| |
$projectnumber |
@@ -1440,7 +1514,12 @@ sub search {
| . $locale->text('Include in Report') . qq| |
- $openclosed
+
+
+ |
+
+ |
+
$delivered
@@ -1452,11 +1531,10 @@ sub search {
. $locale->text('Required by') . qq| |
- $vclabel |
+ $vc_label |
$employee |
|
. $locale->text('Ship via') . qq| |
- $employee |
|
@@ -1465,8 +1543,18 @@ sub search {
. $locale->text('Tax') . qq| |
|
. $locale->text('Total') . qq| |
+
+
+ |
+ . $locale->text('Ertrag') . qq| |
+ |
+ . $locale->text('Ertrag prozentual') . qq| |
+
+
|
. $locale->text('Project Number') . qq| |
+ |
+ . $locale->text('Transaction description') . qq| |
|
@@ -1485,7 +1573,6 @@ $jsscript
-{path}>
{login}>
{password}>
{vc}>
@@ -1502,367 +1589,261 @@ $jsscript
$lxdebug->leave_sub();
}
-sub orders {
+sub create_subtotal_row {
$lxdebug->enter_sub();
- # split vendor / customer
- ($form->{ $form->{vc} }, $form->{"$form->{vc}_id"}) =
- split(/--/, $form->{ $form->{vc} });
+ my ($totals, $columns, $column_alignment, $subtotal_columns, $class) = @_;
- OE->transactions(\%myconfig, \%$form);
+ my $row = { map { $_ => { 'data' => '', 'class' => $class, 'align' => $column_alignment->{$_}, } } @{ $columns } };
- $ordnumber = ($form->{type} =~ /_order$/) ? "ordnumber" : "quonumber";
+ map { $row->{$_}->{data} = $form->format_amount(\%myconfig, $totals->{$_}, 2) } @{ $subtotal_columns };
+
+ $row->{tax}->{data} = $form->format_amount(\%myconfig, $totals->{amount} - $totals->{netamount}, 2);
- $number = $form->escape($form->{$ordnumber});
- $name = $form->escape($form->{ $form->{vc} });
- $department = $form->escape($form->{department});
+ map { $totals->{$_} = 0 } @{ $subtotal_columns };
- # construct href
- $href =
- "$form->{script}?path=$form->{path}&action=orders&type=$form->{type}&vc=$form->{vc}&login=$form->{login}&password=$form->{password}&transdatefrom=$form->{transdatefrom}&transdateto=$form->{transdateto}&open=$form->{open}&closed=$form->{closed}¬delivered=$form->{notdelivered}&delivered=$form->{delivered}&$ordnumber=$number&$form->{vc}=$name&department=$department";
+ $lxdebug->leave_sub();
- # construct callback
- $number = $form->escape($form->{$ordnumber}, 1);
- $name = $form->escape($form->{ $form->{vc} }, 1);
- $department = $form->escape($form->{department}, 1);
+ return $row;
+}
- $callback =
- "$form->{script}?path=$form->{path}&action=orders&type=$form->{type}&vc=$form->{vc}&login=$form->{login}&password=$form->{password}&transdatefrom=$form->{transdatefrom}&transdateto=$form->{transdateto}&open=$form->{open}&closed=$form->{closed}¬delivered=$form->{notdelivered}&delivered=$form->{delivered}&$ordnumber=$number&$form->{vc}=$name&department=$department";
+sub orders {
+ $lxdebug->enter_sub();
- @columns =
- $form->sort_columns("transdate", "reqdate", "id", "$ordnumber",
- "name", "netamount", "tax", "amount",
- "curr", "employee", "shipvia", "globalprojectnumber",
- "open", "closed", "delivered");
+ $ordnumber = ($form->{type} =~ /_order$/) ? "ordnumber" : "quonumber";
- $form->{l_open} = $form->{l_closed} = "Y"
- if ($form->{open} && $form->{closed});
+ ($form->{ $form->{vc} }, $form->{"${form->{vc}}_id"}) = split(/--/, $form->{ $form->{vc} });
- $form->{"l_delivered"} = "Y"
- if ($form->{"delivered"} && $form->{"notdelivered"});
+ $form->{sort} ||= 'transdate';
- foreach $item (@columns) {
- if ($form->{"l_$item"} eq "Y") {
- push @column_index, $item;
+ OE->transactions(\%myconfig, \%$form);
- # add column to href and callback
- $callback .= "&l_$item=Y";
- $href .= "&l_$item=Y";
- }
- }
+ $form->{rowcount} = scalar @{ $form->{OE} };
+
+ my @columns = (
+ "transdate", "reqdate",
+ "id", $ordnumber,
+ "name", "netamount",
+ "tax", "amount",
+ "curr", "employee",
+ "shipvia", "globalprojectnumber",
+ "transaction_description", "open",
+ "delivered", "marge_total", "marge_percent"
+ );
# 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');
- $employee = $locale->text('Salesperson');
+ $form->{title} = $locale->text('Sales Orders');
+ $attachment_basename = $locale->text('sales_order_list');
} else {
- $form->{title} = $locale->text('Quotations');
- $employee = $locale->text('Employee');
+ $form->{title} = $locale->text('Quotations');
+ $attachment_basename = $locale->text('quotation_list');
}
- $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{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;
+ $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();
- print qq|
-
+ # add sort and escape callback, this one we use for the add sub
+ $form->{callback} = $href .= "&sort=$form->{sort}";
-
+ $report->add_separator();
+ $report->add_data(create_subtotal_row(\%totals, \@columns, \%column_alignment, \@subtotal_columns, 'listtotal'));
-
-
-
-
- | | |