X-Git-Url: http://wagnertech.de/git?a=blobdiff_plain;f=bin%2Fmozilla%2Fis.pl;h=b5479473ccdf23912772a2accc070c6e2802532e;hb=f2c923a10719d3a9e26448b7d83f38051466bf2c;hp=4e6a066dbe5c4690375c13161416b374c53719a3;hpb=c103dedd31b5aeb5899c191f2950d2db95e12a79;p=kivitendo-erp.git
diff --git a/bin/mozilla/is.pl b/bin/mozilla/is.pl
index 4e6a066db..b5479473c 100644
--- a/bin/mozilla/is.pl
+++ b/bin/mozilla/is.pl
@@ -33,6 +33,7 @@
use SL::IS;
use SL::PE;
+use Data::Dumper;
require "$form->{path}/io.pl";
require "$form->{path}/arap.pl";
@@ -56,9 +57,10 @@ sub add {
{
$form->error("Access Denied");
}
-
&invoice_links;
&prepare_invoice;
+ $form->{format} = "pdf";
+
&display_form;
$lxdebug->leave_sub();
@@ -73,7 +75,10 @@ sub edit {
{
$form->error("Access Denied");
}
-
+ if ($form->{print_and_post}) {
+ $form->{action} = "print";
+ $form->{resubmit} = 1;
+ }
&invoice_links;
&prepare_invoice;
&display_form;
@@ -186,7 +191,6 @@ sub prepare_invoice {
$form->{type} = "invoice";
$form->{formname} = "invoice";
- $form->{format} = "html";
$form->{media} = "screen";
if ($form->{id}) {
@@ -194,12 +198,14 @@ sub prepare_invoice {
map { $form->{$_} =~ s/\"/"/g }
qw(invnumber ordnumber quonumber shippingpoint shipvia notes intnotes);
+ # # get pricegroups for parts
+ # IS->get_pricegroups_for_parts(\%myconfig, \%$form);
+
foreach $ref (@{ $form->{invoice_details} }) {
$i++;
map { $form->{"${_}_$i"} = $ref->{$_} } keys %{$ref};
$form->{"discount_$i"} =
$form->format_amount(\%myconfig, $form->{"discount_$i"} * 100);
-
($dec) = ($form->{"sellprice_$i"} =~ /\.(\d+)/);
$dec = length $dec;
$decimalplaces = ($dec > 2) ? $dec : 2;
@@ -207,11 +213,17 @@ sub prepare_invoice {
$form->{"sellprice_$i"} =
$form->format_amount(\%myconfig, $form->{"sellprice_$i"},
$decimalplaces);
- $form->{"qty_$i"} = $form->format_amount(\%myconfig, $form->{"qty_$i"});
+
+ (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 partnotes);
$form->{rowcount} = $i;
+
}
}
$lxdebug->leave_sub();
@@ -322,11 +334,20 @@ sub form_header {
text('button') . qq|> |
|;
+ $button3 = qq|
+ {deliverydate}> |
+ text('button') . qq|> |
+ |;
#write Trigger
$jsscript =
- Form->write_trigger(\%myconfig, "2", "invdate", "BL", "trigger1",
- "duedate", "BL", "trigger2");
+ Form->write_trigger(\%myconfig, "3",
+ "invdate", "BL",
+ "trigger1", "duedate",
+ "BL", "trigger2",
+ "deliverydate", "BL",
+ "trigger3");
} else {
# without JavaScript Calendar
@@ -335,8 +356,11 @@ sub form_header {
$button2 =
qq|{duedate}> | |;
}
- if ($form->{resubmit}) {
- $onload = "document.invoice.submit()";
+ if ($form->{resubmit} && ($form->{format} eq "html")) {
+ $onload =
+ qq|window.open('about:blank','Beleg'); document.invoice.target = 'Beleg';document.invoice.submit()|;
+ } elsif ($form->{resubmit}) {
+ $onload = qq|document.invoice.submit()|;
} else {
$onload = "fokus()";
}
@@ -389,6 +413,7 @@ sub form_header {
| . $locale->text('Customer') . qq| |
$customer |
+ {customer_klass}>
{customer_id}>
|
@@ -455,6 +480,10 @@ sub form_header {
| | . $locale->text('Due Date') . qq| |
$button2
+
+ | . $locale->text('Delivery Date') . qq| |
+ $button3
+
| . $locale->text('Order Number') . qq| |
|
@@ -753,8 +782,6 @@ sub form_footer {
{oldinvtotal}>
-{print_and_post}>
-{second_run}>
@@ -855,7 +882,9 @@ sub update {
map { $form->{$_} = $form->parse_amount(\%myconfig, $form->{$_}) }
qw(exchangerate creditlimit creditremaining);
-
+ if ($form->{second_run}) {
+ $form->{print_and_post} = 0;
+ }
&check_name(customer);
&check_project;
@@ -973,6 +1002,11 @@ sub update {
}
}
+ # get pricegroups for parts
+ IS->get_pricegroups_for_parts(\%myconfig, \%$form);
+
+ # build up html code for prices_$i
+ &set_pricegroup($i);
}
&display_form;
@@ -1003,7 +1037,6 @@ sub update {
sub post {
$lxdebug->enter_sub();
-
$form->isblank("invdate", $locale->text('Invoice Date missing!'));
$form->isblank("customer", $locale->text('Customer missing!'));
@@ -1012,6 +1045,9 @@ sub post {
&update;
exit;
}
+ if ($form->{second_run}) {
+ $form->{print_and_post} = 0;
+ }
&validate_items;
@@ -1025,7 +1061,7 @@ sub post {
if ($form->{currency} ne $form->{defaultcurrency});
for $i (1 .. $form->{paidaccounts}) {
- if ($form->{"paid_$i"}) {
+ if ($form->parse_amount(\%myconfig, $form->{"paid_$i"})) {
$datepaid = $form->datetonum($form->{"datepaid_$i"}, \%myconfig);
$form->isblank("datepaid_$i", $locale->text('Payment date missing!'));
@@ -1049,8 +1085,10 @@ sub post {
$form->{id} = 0 if $form->{postasnew};
- $form->{invnumber} = $form->update_defaults(\%myconfig, "invnumber")
- unless $form->{invnumber};
+ # get new invnumber in sequence if no invnumber is given or if posasnew was requested
+ if (!$form->{invnumber} || $form->{postasnew}) {
+ $form->{invnumber} = $form->update_defaults(\%myconfig, "invnumber");
+ }
if ($print_post) {
if (!(IS->post_invoice(\%myconfig, \%$form))) {
$form->error($locale->text('Cannot post invoice!'));
@@ -1072,7 +1110,8 @@ sub print_and_post {
$print_post = 1;
$form->{print_and_post} = 1;
&post();
- &display_form();
+
+ &edit();
$lxdebug->leave_sub();
}
@@ -1092,7 +1131,9 @@ sub preview {
sub delete {
$lxdebug->enter_sub();
-
+ if ($form->{second_run}) {
+ $form->{print_and_post} = 0;
+ }
$form->header;
print qq|