X-Git-Url: http://wagnertech.de/git?a=blobdiff_plain;f=bin%2Fmozilla%2Fio.pl;h=d205161dc94d6ae1d6eef1369223f99a8268a217;hb=6d1df9ca24bbb8c03e10812ce4cf1b889d947470;hp=fa19d2547e74f97be02b1602e40c91de85dc831b;hpb=d629acd82a27e980899a044ca8b0f4becc8e94bb;p=kivitendo-erp.git
diff --git a/bin/mozilla/io.pl b/bin/mozilla/io.pl
index fa19d2547..d205161dc 100644
--- a/bin/mozilla/io.pl
+++ b/bin/mozilla/io.pl
@@ -33,6 +33,7 @@
#
#######################################################################
+use SL::Common;
use SL::CT;
use SL::IC;
use CGI::Ajax;
@@ -91,6 +92,11 @@ sub display_row {
$lxdebug->enter_sub();
my $numrows = shift;
+ my $is_sales =
+ (substr($form->{type}, 0, 6) eq "sales_")
+ || (($form->{type} eq "invoice") && ($form->{script} eq "is.pl"))
+ || ($form->{type} eq 'credit_note');
+
if ($lizenzen && $form->{vc} eq "customer") {
if ($form->{type} =~ /sales_order/) {
@column_index = (runningnumber, partnumber, description, ship, qty);
@@ -241,6 +247,9 @@ sub display_row {
$delvar = 'reqdate';
}
+ $form->{marge_total} = 0;
+ $form->{sellprice_total} = 0;
+ $form->{lastcost_total} = 0;
my %projectnumber_labels = ();
my @projectnumber_values = ("");
foreach my $item (@{ $form->{"ALL_PROJECTS"} }) {
@@ -300,6 +309,34 @@ sub display_row {
$linetotal =
$form->round_amount($form->{"sellprice_$i"} - $discount, $decimalplaces);
$linetotal = $form->round_amount($linetotal * $form->{"qty_$i"}, 2);
+ my $real_sellprice = $form->{"sellprice_$i"} - $discount;
+
+ # marge calculations
+ my ($marge_font_start, $marge_font_end);
+
+ $form->{"lastcost_$i"} *= 1;
+
+ if ($real_sellprice && ($form->{"qty_$i"} * 1)) {
+ $form->{"marge_percent_$i"} = ($real_sellprice - $form->{"lastcost_$i"}) * 100 / $real_sellprice;
+ $myconfig{"marge_percent_warn"} = 15 unless (defined($myconfig{"marge_percent_warn"}));
+
+ if ($form->{"id_$i"} &&
+ ($form->{"marge_percent_$i"} < (1 * $myconfig{"marge_percent_warn"}))) {
+ $marge_font_start = "";
+ $marge_font_end = "";
+ }
+
+ } else {
+ $form->{"marge_percent_$i"} = 0;
+ }
+
+ my $marge_adjust_credit_note = $form->{type} eq 'credit_note' ? -1 : 1;
+ $form->{"marge_absolut_$i"} = ($real_sellprice - $form->{"lastcost_$i"}) * $form->{"qty_$i"} * $marge_adjust_credit_note;
+ $form->{"marge_total"} += $form->{"marge_absolut_$i"};
+ $form->{"lastcost_total"} += $form->{"lastcost_$i"} * $form->{"qty_$i"};
+ $form->{"sellprice_total"} += $real_sellprice * $form->{"qty_$i"};
+
+ map { $form->{"${_}_$i"} = $form->format_amount(\%myconfig, $form->{"${_}_$i"}, 2) } qw(marge_absolut marge_percent);
# convert " to "
map { $form->{"${_}_$i"} =~ s/\"/"/g }
@@ -331,9 +368,10 @@ sub display_row {
qq|
|;
if ($form->{"formel_$i"}) {
- $column_data{qty} .= qq|| .
- $cgi->hidden("-name" => "formel_$i", "-value" => $form->{"formel_$i"}) . $cgi->hidden("-name" => "alu_$i", "-value" => $form->{"alu_$i"}). qq| | |;
+ $column_data{qty} .= qq||
+ . $cgi->hidden("-name" => "formel_$i", "-value" => $form->{"formel_$i"}) . $cgi->hidden("-name" => "alu_$i", "-value" => $form->{"alu_$i"});
}
+ $column_data{qty} .= qq||;
$column_data{ship} =
qq|{"subtotal_$i"}) ? "checked" : "";
print qq|
|.$locale->text('Subtotal').qq|
+|;
+
+ if ($form->{"id_$i"} && $is_sales) {
+ print qq|
+ ${marge_font_start}| . $locale->text('Ertrag') . qq| $form->{"marge_absolut_$i"} $form->{"marge_percent_$i"} % ${marge_font_end}
+ | . $locale->text('LP') . qq| | . $form->format_amount(\%myconfig, $form->{"listprice_$i"}, 2) . qq|
+ | . $locale->text('EK') . qq| | . $form->format_amount(\%myconfig, $form->{"lastcost_$i"}, 2);
+ }
+
+ print qq|
|
-
|;
############## ENDE Neueintrag ##################
@@ -511,6 +558,10 @@ sub display_row {
|;
+ if (0 != ($form->{sellprice_total} * 1)) {
+ $form->{marge_percent} = ($form->{sellprice_total} - $form->{lastcost_total}) / $form->{sellprice_total} * 100;
+ }
+
$lxdebug->leave_sub();
}
@@ -646,12 +697,12 @@ sub select_item {
my @new_fields =
qw(bin listprice inventory_accno income_accno expense_accno unit weight
- assembly taxaccounts partsgroup formel logdescription not_discountable
- part_payment_id partnodes id);
+ assembly taxaccounts partsgroup formel longdescription not_discountable
+ part_payment_id partnotes id lastcost);
push(@new_fields, "lizenzen") if ($lizenzen);
- map({ print($cgi->hidden("-name" => "new_${_}_$i",
- "-value" => $ref->{$_})); } @new_fields);
+ print join "\n", map { $cgi->hidden("-name" => "new_${_}_$i", "-value" => $ref->{$_}) } @new_fields;
+ print "\n";
}
print qq|
@@ -706,7 +757,7 @@ sub item_selected {
map { $form->{"${_}_$i"} = $form->{"new_${_}_$j"} }
qw(id partnumber description sellprice listprice inventory_accno
income_accno expense_accno bin unit weight assembly taxaccounts
- partsgroup formel longdescription not_discountable partnotes);
+ partsgroup formel longdescription not_discountable partnotes lastcost);
if ($form->{"part_payment_id_$i"} ne "") {
$form->{payment_id} = $form->{"part_payment_id_$i"};
}
@@ -946,7 +997,7 @@ sub check_form {
my @a = ();
my $count = 0;
my @flds = (
- qw(id partnumber description qty ship sellprice unit discount inventory_accno income_accno expense_accno listprice taxaccounts bin assembly weight projectnumber project_id oldprojectnumber runningnumber serialnumber partsgroup payment_id not_discountable shop ve gv buchungsgruppen_id language_values sellprice_pg pricegroup_old price_old price_new unit_old ordnumber transdate longdescription basefactor)
+ qw(id partnumber description qty ship sellprice unit discount inventory_accno income_accno expense_accno listprice taxaccounts bin assembly weight projectnumber project_id oldprojectnumber runningnumber serialnumber partsgroup payment_id not_discountable shop ve gv buchungsgruppen_id language_values sellprice_pg pricegroup_old price_old price_new unit_old ordnumber transdate longdescription basefactor marge_absolut marge_percent lastcost )
);
@@ -1018,6 +1069,9 @@ sub check_form {
$form->redo_rows(\@flds, \@a, $count, $form->{makemodel_rows});
$form->{makemodel_rows} = $count;
+ } elsif ($form->{item} eq 'service') {
+ map { $form->{$_} = $form->parse_amount(\%myconfig, $form->{$_}) } qw(listprice sellprice lastcost);
+
} else {
# this section applies to invoices and orders
@@ -1129,6 +1183,9 @@ sub order {
}
$form->{ordnumber} = $form->{invnumber};
+ $form->{old_employee_id} = $form->{employee_id};
+ $form->{old_salesman_id} = $form->{salesman_id};
+
map { delete $form->{$_} } qw(id printed emailed queued);
if ($form->{script} eq 'ir.pl' || $form->{type} eq 'request_quotation') {
$form->{title} = $locale->text('Add Purchase Order');
@@ -1256,166 +1313,36 @@ sub edit_e_mail {
$form->{print_and_post} = 0;
$form->{resubmit} = 0;
}
- if ($myconfig{role} eq 'admin') {
- $bcc = qq|
-
- | . $locale->text('Bcc') . qq| |
- |
-
-|;
- }
- if ($form->{formname} =~ /(pick|packing|bin)_list/) {
- $form->{email} = $form->{shiptoemail} if $form->{shiptoemail};
- }
+ $form->{email} = $form->{shiptoemail} if $form->{shiptoemail} && $form->{formname} =~ /(pick|packing|bin)_list/;
if ($form->{"cp_id"} && !$form->{"email"}) {
CT->get_contact(\%myconfig, $form);
$form->{"email"} = $form->{"cp_email"};
}
- $name = $form->{ $form->{vc} };
- $name =~ s/--.*//g;
- $title = $locale->text('E-mail') . " $name";
+ $form->{ $form->{vc} } =~ /--/;
+ $title = $locale->text('E-mail') . " $`";
$form->{oldmedia} = $form->{media};
$form->{media} = "email";
- my %formname_translations =
- (
- "bin_list" => $locale->text('Bin List'),
- "credit_note" => $locale->text('Credit Note'),
- "invoice" => $locale->text('Invoice'),
- "packing_list" => $locale->text('Packing List'),
- "pick_list" => $locale->text('Pick List'),
- "proforma" => $locale->text('Proforma Invoice'),
- "purchase_order" => $locale->text('Purchase Order'),
- "request_quotation" => $locale->text('RFQ'),
- "sales_order" => $locale->text('Confirmation'),
- "sales_quotation" => $locale->text('Quotation'),
- "storno_invoice" => $locale->text('Storno Invoice'),
- "storno_packing_list" => $locale->text('Storno Packing List'),
- );
-
- my $attachment_filename = $formname_translations{$form->{"formname"}};
- my $prefix;
-
- if (grep({ $form->{"type"} eq $_ } qw(invoice credit_note))) {
- $prefix = "inv";
- } elsif ($form->{"type"} =~ /_quotation$/) {
- $prefix = "quo";
- } else {
- $prefix = "ord";
- }
-
- if ($attachment_filename && $form->{"${prefix}number"}) {
- $attachment_filename .= "_" . $form->{"${prefix}number"} .
- ($form->{"format"} =~ /pdf/i ? ".pdf" :
- $form->{"format"} =~ /postscript/i ? ".ps" :
- $form->{"format"} =~ /opendocument/i ? ".odt" :
- $form->{"format"} =~ /html/i ? ".html" : "");
- $attachment_filename =~ s/ /_/g;
- my %umlaute =
- (
- "ä" => "ae", "ö" => "oe", "ü" => "ue",
- "Ä" => "Ae", "Ö" => "Oe", "Ü" => "Ue",
- "ß" => "ss"
- );
- map({ $attachment_filename =~ s/$_/$umlaute{$_}/g; } keys(%umlaute));
- } else {
- $attachment_filename = "";
- }
+ my $attachment_filename = $form->generate_attachment_filename();
- if ($form->{"email"}) {
- $form->{"fokus"} = "Form.subject";
- } else {
- $form->{"fokus"} = "Form.email";
- }
+ $form->{"fokus"} = $form->{"email"} ? "Form.subject" : "Form.email";
$form->header;
- print qq|
-
+ my (@dont_hide_key_list, %dont_hide_key, @hidden_keys);
+ @dont_hide_key_list = qw(action email cc bcc subject message formname sendmode format header override);
+ @dont_hide_key{@dont_hide_key_list} = (1) x @dont_hide_key_list;
+ @hidden_keys = grep { !$dont_hide_key{$_} } grep { !ref $form->{$_} } keys %$form;
-
-
-
-