X-Git-Url: http://wagnertech.de/git?a=blobdiff_plain;f=bin%2Fmozilla%2Foe.pl;h=bb6684858d55d2aaaff0f02aafa4bb8773dd65f6;hb=8423c7b21bc3b4b2db7d0ffef756919619336e97;hp=6f12c94d37e156c9bc660ea2b8d0abfabc4d39ec;hpb=f9f5330a26eb3f447677ab2524c823cb9f96723b;p=kivitendo-erp.git
diff --git a/bin/mozilla/oe.pl b/bin/mozilla/oe.pl
index 6f12c94d3..bb6684858 100644
--- a/bin/mozilla/oe.pl
+++ b/bin/mozilla/oe.pl
@@ -44,26 +44,59 @@ require "$form->{path}/arap.pl";
# end of main
-sub add {
+# For locales.pl:
+# $locale->text('Edit the purchase_order');
+# $locale->text('Edit the sales_order');
+# $locale->text('Edit the request_quotation');
+# $locale->text('Edit the sales_quotation');
+
+# $locale->text('Workflow purchase_order');
+# $locale->text('Workflow sales_order');
+# $locale->text('Workflow request_quotation');
+# $locale->text('Workflow sales_quotation');
+
+sub set_headings {
$lxdebug->enter_sub();
+ my ($action) = @_;
+
if ($form->{type} eq 'purchase_order') {
- $form->{title} = $locale->text('Add Purchase Order');
- $form->{vc} = 'vendor';
+ $form->{title} = $action eq "edit" ?
+ $locale->text('Edit Purchase Order') :
+ $locale->text('Add Purchase Order');
+ $form->{heading} = $locale->text('Purchase Order');
+ $form->{vc} = 'vendor';
}
if ($form->{type} eq 'sales_order') {
- $form->{title} = $locale->text('Add Sales Order');
- $form->{vc} = 'customer';
+ $form->{title} = $action eq "edit" ?
+ $locale->text('Edit Sales Order') :
+ $locale->text('Add Sales Order');
+ $form->{heading} = $locale->text('Sales Order');
+ $form->{vc} = 'customer';
}
if ($form->{type} eq 'request_quotation') {
- $form->{title} = $locale->text('Add Request for Quotation');
- $form->{vc} = 'vendor';
+ $form->{title} = $action eq "edit" ?
+ $locale->text('Edit Request for Quotation') :
+ $locale->text('Add Request for Quotation');
+ $form->{heading} = $locale->text('Request for Quotation');
+ $form->{vc} = 'vendor';
}
if ($form->{type} eq 'sales_quotation') {
- $form->{title} = $locale->text('Add Quotation');
- $form->{vc} = 'customer';
+ $form->{title} = $action eq "edit" ?
+ $locale->text('Edit Quotation') :
+ $locale->text('Add Quotation');
+ $form->{heading} = $locale->text('Quotation');
+ $form->{vc} = 'customer';
}
+ $lxdebug->leave_sub();
+}
+
+sub add {
+ $lxdebug->enter_sub();
+
+ set_headings("add");
+
$form->{callback} =
"$form->{script}?action=add&type=$form->{type}&vc=$form->{vc}&login=$form->{login}&path=$form->{path}&password=$form->{password}"
unless $form->{callback};
@@ -78,6 +111,10 @@ sub add {
sub edit {
$lxdebug->enter_sub();
+ $form->{simple_save} = 0;
+
+ set_headings("edit");
+
# editing without stuff to edit? try adding it first
if ($form->{rowcount}) {
map { $id++ if $form->{"id_$_"} } (1 .. $form->{rowcount});
@@ -95,29 +132,21 @@ sub edit {
}
}
- if ($form->{type} eq 'purchase_order') {
- $form->{title} = $locale->text('Edit Purchase Order');
- $form->{heading} = $locale->text('Purchase Order');
- $form->{vc} = 'vendor';
- }
- if ($form->{type} eq 'sales_order') {
- $form->{title} = $locale->text('Edit Sales Order');
- $form->{heading} = $locale->text('Sales Order');
- $form->{vc} = 'customer';
- }
- if ($form->{type} eq 'request_quotation') {
- $form->{title} = $locale->text('Edit Request for Quotation');
- $form->{heading} = $locale->text('Request for Quotation');
- $form->{vc} = 'vendor';
- }
- if ($form->{type} eq 'sales_quotation') {
- $form->{title} = $locale->text('Edit Quotation');
- $form->{heading} = $locale->text('Quotation');
- $form->{vc} = 'customer';
+ if ($form->{print_and_save}) {
+ $form->{action} = "print";
+ $form->{resubmit} = 1;
+ $language_id = $form->{language_id};
+ $printer_id = $form->{printer_id};
}
+ set_headings("edit");
+
&order_links;
&prepare_order;
+ if ($form->{print_and_save}) {
+ $form->{language_id} = $language_id;
+ $form->{printer_id} = $printer_id;
+ }
&display_form;
$lxdebug->leave_sub();
@@ -132,12 +161,22 @@ sub order_links {
# retrieve order/quotation
$form->{webdav} = $webdav;
-
# set jscalendar
$form->{jscalendar} = $jscalendar;
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};
+ }
+
+
# 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)
@@ -185,7 +224,15 @@ sub order_links {
}
$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;
($form->{ $form->{vc} }) = split /--/, $form->{ $form->{vc} };
$form->{"old$form->{vc}"} =
@@ -200,7 +247,7 @@ sub order_links {
}
# currencies
- @curr = split /:/, $form->{currencies};
+ @curr = split(/:/, $form->{currencies});
chomp $curr[0];
$form->{defaultcurrency} = $curr[0];
$form->{currency} = $form->{defaultcurrency} unless $form->{currency};
@@ -237,13 +284,10 @@ sub order_links {
sub prepare_order {
$lxdebug->enter_sub();
- $form->{format} = "pdf";
$form->{media} = "screen";
- $form->{formname} = $form->{type};
-
- map { $form->{$_} =~ s/\"/"/g }
- qw(ordnumber quonumber shippingpoint shipvia notes intnotes shiptoname shiptostreet shiptozipcode shiptocity shiptocountry shiptocontact);
+ $form->{formname} = $form->{type} unless $form->{formname};
+ my $i = 0;
foreach $ref (@{ $form->{form_details} }) {
$form->{rowcount} = ++$i;
@@ -287,10 +331,23 @@ sub form_header {
$checkedopen = ($form->{closed}) ? "" : "checked";
$checkedclosed = ($form->{closed}) ? "checked" : "";
+ map { $form->{$_} =~ s/\"/"/g }
+ qw(ordnumber quonumber shippingpoint shipvia notes intnotes shiptoname
+ shiptostreet shiptozipcode shiptocity shiptocountry shiptocontact
+ shiptophone shiptofax shiptodepartment_1 shiptodepartment_2);
+
# use JavaScript Calendar or not
$form->{jsscript} = $form->{jscalendar};
$jsscript = "";
+ $payment = qq||;
+ foreach $item (@{ $form->{payment_terms} }) {
+ if ($form->{payment_id} eq $item->{id}) {
+ $payment .= qq||;
+ } else {
+ $payment .= qq||;
+ }
+ }
if ($form->{jsscript}) {
# with JavaScript Calendar
@@ -337,7 +394,7 @@ sub form_header {
}
# set option selected
- foreach $item ($form->{vc}, currency, department, employee, contact) {
+ foreach $item ($form->{vc}, currency, department, employee) {
$form->{"select$item"} =~ s/ selected//;
$form->{"select$item"} =~
s/option>\Q$form->{$item}\E/option selected>$form->{$item}/;
@@ -349,20 +406,61 @@ sub form_header {
#build contacts
if ($form->{all_contacts}) {
- $form->{selectcontact} = "";
+ $form->{selectcontact} = "";
foreach $item (@{ $form->{all_contacts} }) {
+ my $department = ($item->{cp_abteilung}) ? "--$item->{cp_abteilung}" : "";
if ($form->{cp_id} == $item->{cp_id}) {
$form->{selectcontact} .=
- "";
} else {
- $form->{selectcontact} .= "";
}
}
+ } else {
+ $form->{selectcontact} =~ s/ selected//g;
+ if ($form->{cp_id} ne "") {
+ $form->{selectcontact} =~ s/value=$form->{cp_id}/value=$form->{cp_id} selected/;
+ }
}
+
+ if (@{ $form->{SHIPTO} }) {
+ $form->{selectshipto} = "";
+ foreach $item (@{ $form->{SHIPTO} }) {
+ if ($item->{shipto_id} == $form->{shipto_id}) {
+ $form->{selectshipto} .=
+ "";
+ } else {
+ $form->{selectshipto} .=
+ "";
+ }
+
+ }
+ } else {
+ $form->{selectshipto} = $form->unquote($form->{selectshipto});
+ $form->{selectshipto} =~ s/ selected//g;
+ if ($form->{shipto_id} ne "") {
+ $form->{selectshipto} =~ s/value=$form->{shipto_id}/value=$form->{shipto_id} selected/;
+ }
+ }
+
+ $shipto = qq|
+
| . $locale->text('Shipping Address') . qq| |
+ | |;
+ $form->{selectshipto} = $form->quote($form->{selectshipto});
+ $shipto .= 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} =
@@ -370,7 +468,7 @@ sub form_header {
$contact =
($form->{selectcontact})
- ? qq|\n|
+ ? qq|\n|
: qq||;
$exchangerate = qq|
@@ -396,13 +494,7 @@ sub form_header {
$vclabel = ucfirst $form->{vc};
$vclabel = $locale->text($vclabel);
- $terms = qq|
-
- | . $locale->text('Terms: Net') . qq| |
- {terms}> |
- . $locale->text('days') . qq| |
-
-|;
+
if ($form->{business}) {
$business = qq|
@@ -417,6 +509,53 @@ sub form_header {
|;
}
+ 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->{TAXZONE} }) {
+ $form->{selecttaxzone} = "";
+ foreach $item (@{ $form->{TAXZONE} }) {
+ if ($item->{id} == $form->{taxzone_id}) {
+ $form->{selecttaxzone} .=
+ "";
+ } else {
+ $form->{selecttaxzone} .=
+ "";
+ }
+
+ }
+ } else {
+ $form->{selecttaxzone} =~ s/ selected//g;
+ if ($form->{taxzone_id} ne "") {
+ $form->{selecttaxzone} =~ s/value=$form->{taxzone_id}>/value=$form->{taxzone_id} selected>/;
+ }
+ }
+
+ $taxzone = qq|
+
+ | . $locale->text('Steuersatz') . qq| |
+ |
+
+
|;
+
+
if ($form->{type} !~ /_quotation$/) {
$ordnumber = qq|
@@ -456,10 +595,11 @@ sub form_header {
$form->{creditlimit} |
|
| . $locale->text('Remaining') . qq| |
- $form->{creditremaining} |
+ $form->{creditremaining} |
+ $shipto
|;
} else {
@@ -485,7 +625,6 @@ sub form_header {
|;
- $terms = "";
}
$ordnumber .= qq|
@@ -498,7 +637,10 @@ sub form_header {
$button2
|;
-
+ $creditremaining = qq|
+ |
+ $shipto
+
|;
}
$vc =
@@ -542,20 +684,41 @@ sub form_header {
|;
}
+ 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 = "fokus()";
+ }
+
+ $credittext = $locale->text('Credit Limit exceeded!!!');
+ if ($creditwarning) {
+ $onload = qq|alert('$credittext')|;
+ }
+
+ $form->{"javascript"} .= qq||;
$form->header;
print qq|
-
+
-
@@ -1693,7 +1886,7 @@ sub subtotal {
$lxdebug->leave_sub();
}
-sub save {
+sub save_and_close {
$lxdebug->enter_sub();
if ($form->{type} =~ /_order$/) {
@@ -1754,8 +1947,12 @@ sub save {
}
- $form->{$ordnumber} = $form->update_defaults(\%myconfig, $numberfld)
- unless $form->{$ordnumber};
+ # get new number in sequence if no number is given or if saveasnew was requested
+ if (!$form->{$ordnumber} || $form->{saveasnew}) {
+ $form->{$ordnumber} = $form->update_defaults(\%myconfig, $numberfld);
+ }
+
+ relink_accounts();
$form->redirect(
$form->{label} . " $form->{$ordnumber} " . $locale->text('saved!'))
@@ -1765,6 +1962,82 @@ sub save {
$lxdebug->leave_sub();
}
+sub save {
+ $lxdebug->enter_sub();
+
+ if ($form->{type} =~ /_order$/) {
+ $form->isblank("transdate", $locale->text('Order Date missing!'));
+ } else {
+ $form->isblank("transdate", $locale->text('Quotation Date missing!'));
+ }
+
+ $msg = ucfirst $form->{vc};
+ $form->isblank($form->{vc}, $locale->text($msg . " missing!"));
+
+ # $locale->text('Customer missing!');
+ # $locale->text('Vendor missing!');
+
+ $form->isblank("exchangerate", $locale->text('Exchangerate missing!'))
+ if ($form->{currency} ne $form->{defaultcurrency});
+
+ &validate_items;
+
+ # if the name changed get new values
+ if (&check_name($form->{vc})) {
+ &update;
+ exit;
+ }
+
+ $form->{id} = 0 if $form->{saveasnew};
+
+ # this is for the internal notes section for the [email] Subject
+ if ($form->{type} =~ /_order$/) {
+ if ($form->{type} eq 'sales_order') {
+ $form->{label} = $locale->text('Sales Order');
+
+ $numberfld = "sonumber";
+ $ordnumber = "ordnumber";
+ } else {
+ $form->{label} = $locale->text('Purchase Order');
+
+ $numberfld = "ponumber";
+ $ordnumber = "ordnumber";
+ }
+
+ $err = $locale->text('Cannot save order!');
+
+ } else {
+ if ($form->{type} eq 'sales_quotation') {
+ $form->{label} = $locale->text('Quotation');
+
+ $numberfld = "sqnumber";
+ $ordnumber = "quonumber";
+ } else {
+ $form->{label} = $locale->text('Request for Quotation');
+
+ $numberfld = "rfqnumber";
+ $ordnumber = "quonumber";
+ }
+
+ $err = $locale->text('Cannot save quotation!');
+
+ }
+
+ $form->{$ordnumber} = $form->update_defaults(\%myconfig, $numberfld)
+ unless $form->{$ordnumber};
+
+ relink_accounts();
+
+ OE->save(\%myconfig, \%$form);
+ $form->{simple_save} = 1;
+ if(!$form->{print_and_save}) {
+ set_headings("edit");
+ &update;
+ exit;
+ }
+ $lxdebug->leave_sub();
+}
+
sub delete {
$lxdebug->enter_sub();
@@ -1853,9 +2126,15 @@ sub invoice {
exit;
}
- ($null, $form->{cp_id}) = split /--/, $form->{contact};
$form->{cp_id} *= 1;
+ for $i (1 .. $form->{rowcount}) {
+ map({ $form->{"${_}_${i}"} = $form->parse_amount(\%myconfig,
+ $form->{"${_}_${i}"})
+ if ($form->{"${_}_${i}"}) }
+ qw(ship qty sellprice listprice basefactor));
+ }
+
if ( $form->{type} =~ /_order/
&& $form->{currency} ne $form->{defaultcurrency}) {
@@ -1880,7 +2159,7 @@ sub invoice {
# if not it's most likely a collective order, which can't be saved back
# so they just have to be closed
if (($form->{ordnumber} ne '') || ($form->{quonumber} ne '')) {
- OE->save(\%myconfig, \%$form);
+ OE->close_order(\%myconfig, \%$form);
} else {
OE->close_orders(\%myconfig, \%$form);
}
@@ -2104,6 +2383,8 @@ sub create_backorder {
} qw(sellprice discount);
}
+ relink_accounts();
+
OE->save(\%myconfig, \%$form);
# rebuild rows for invoice
@@ -2132,7 +2413,7 @@ sub save_as_new {
$form->{saveasnew} = 1;
$form->{closed} = 0;
- map { delete $form->{$_} } qw(printed emailed queued);
+ map { delete $form->{$_} } qw(printed emailed queued ordnumber quonumber);
&save;
@@ -2144,11 +2425,9 @@ sub purchase_order {
if ( $form->{type} eq 'sales_quotation'
|| $form->{type} eq 'request_quotation') {
- $form->{closed} = 1;
- OE->save(\%myconfig, \%$form);
+ OE->close_order(\%myconfig, \%$form);
}
- ($null, $form->{cp_id}) = split /--/, $form->{contact};
$form->{cp_id} *= 1;
$form->{title} = $locale->text('Add Purchase Order');
@@ -2165,11 +2444,9 @@ sub sales_order {
if ( $form->{type} eq 'sales_quotation'
|| $form->{type} eq 'request_quotation') {
- $form->{closed} = 1;
- OE->save(\%myconfig, \%$form);
+ OE->close_order(\%myconfig, $form);
}
- ($null, $form->{cp_id}) = split /--/, $form->{contact};
$form->{cp_id} *= 1;
$form->{title} = $locale->text('Add Sales Order');
@@ -2193,6 +2470,13 @@ sub poso {
map { delete $form->{$_} }
qw(id subject message cc bcc printed emailed queued customer vendor creditlimit creditremaining discount tradediscount oldinvtotal);
+ for $i (1 .. $form->{rowcount}) {
+ map({ $form->{"${_}_${i}"} = $form->parse_amount(\%myconfig,
+ $form->{"${_}_${i}"})
+ if ($form->{"${_}_${i}"}) }
+ qw(ship qty sellprice listprice basefactor));
+ }
+
&order_links;
&prepare_order;
@@ -2400,6 +2684,8 @@ sub display_ship_receive {
+
+
@@ -2545,14 +2831,6 @@ sub display_ship_receive {
-|;
-
- if ($form->{menubar}) {
- require "$form->{path}/menu.pl";
- &menubar;
- }
-
- print qq|
{rowcount}>
@@ -2824,14 +3102,8 @@ sub list_transfer {
{password}>
|;
+ . $locale->text('Transfer') . qq|">
- if ($form->{menubar}) {
- require "$form->{path}/menu.pl";
- &menubar;
- }
-
- print qq|