X-Git-Url: http://wagnertech.de/git?a=blobdiff_plain;ds=sidebyside;f=bin%2Fmozilla%2Fis.pl;h=f39ff1368d6150f486b3272dc81220654fd88266;hb=177518a0430a0de7576c2eb054761636711ca792;hp=8c1249334c3d414291c3d3d723ca13c9246849e4;hpb=da10bf753ae49b8322e79fc1bb9276a092403b9a;p=kivitendo-erp.git
diff --git a/bin/mozilla/is.pl b/bin/mozilla/is.pl
index 8c1249334..f39ff1368 100644
--- a/bin/mozilla/is.pl
+++ b/bin/mozilla/is.pl
@@ -31,12 +31,15 @@
#
#======================================================================
+use SL::FU;
use SL::IS;
use SL::PE;
use Data::Dumper;
+use List::Util qw(max sum);
-require "$form->{path}/io.pl";
-require "$form->{path}/arap.pl";
+require "bin/mozilla/io.pl";
+require "bin/mozilla/invoice_io.pl";
+require "bin/mozilla/arap.pl";
require "bin/mozilla/drafts.pl";
1;
@@ -46,6 +49,8 @@ require "bin/mozilla/drafts.pl";
sub add {
$lxdebug->enter_sub();
+ $auth->assert('invoice_edit');
+
return $lxdebug->leave_sub() if (load_draft_maybe());
if ($form->{type} eq "credit_note") {
@@ -60,16 +65,10 @@ sub add {
}
- $form->{callback} =
- "$form->{script}?action=add&type=$form->{type}&login=$form->{login}&path=$form->{path}&password=$form->{password}"
- unless $form->{callback};
+ $form->{callback} = "$form->{script}?action=add&type=$form->{type}" unless $form->{callback};
$form{jsscript} = "date";
- if ($myconfig{acs} =~ "AR--Add Sales Invoice" || $myconfig{acs} =~ "AR--AR")
- {
- $form->error("Access Denied");
- }
&invoice_links;
&prepare_invoice;
&display_form;
@@ -80,14 +79,12 @@ sub add {
sub edit {
$lxdebug->enter_sub();
+ $auth->assert('invoice_edit');
+
# show history button
$form->{javascript} = qq||;
#/show hhistory button
-
- if ($myconfig{acs} =~ "AR--Add Sales Invoice" || $myconfig{acs} =~ "AR--AR")
- {
- $form->error("Access Denied");
- }
+
$edit = 1;
if ($form->{print_and_post}) {
$form->{action} = "print";
@@ -110,6 +107,8 @@ sub edit {
sub invoice_links {
$lxdebug->enter_sub();
+ $auth->assert('invoice_edit');
+
$form->{vc} = 'customer';
# create links
@@ -167,21 +166,8 @@ sub invoice_links {
$form->{shipto_id} = $shipto_id;
}
- # currencies
- @curr = split(/:/, $form->{currencies});
- chomp $curr[0];
- $form->{defaultcurrency} = $curr[0];
-
- map { $form->{selectcurrency} .= "\n"
} (@{ $form->{all_departments} });
}
$form->{employee} = "$form->{employee}--$form->{employee_id}";
- # sales staff
- if ($form->{all_employees}) {
- $form->{selectemployee} = "";
- map { $form->{selectemployee} .= "\n";
}
if ($key eq "AR_paid") {
@@ -248,6 +228,8 @@ sub invoice_links {
sub prepare_invoice {
$lxdebug->enter_sub();
+ $auth->assert('invoice_edit');
+
if ($form->{type} eq "credit_note") {
$form->{type} = "credit_note";
$form->{formname} = "credit_note";
@@ -258,8 +240,6 @@ sub prepare_invoice {
if ($form->{id}) {
- map { $form->{$_} =~ s/\"/"/g }
- qw(invnumber ordnumber quonumber shippingpoint shipvia notes intnotes);
# # get pricegroups for parts
# IS->get_pricegroups_for_parts(\%myconfig, \%$form);
@@ -286,8 +266,6 @@ sub prepare_invoice {
$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;
}
@@ -298,25 +276,22 @@ sub prepare_invoice {
sub form_header {
$lxdebug->enter_sub();
- if ($edit) {
+ $auth->assert('invoice_edit');
+ $form->{employee_id} = $form->{old_employee_id} if $form->{old_employee_id};
+ $form->{salesman_id} = $form->{old_salesman_id} if $form->{old_salesman_id};
+
+ if ($edit) {
if ($form->{type} eq "credit_note") {
$form->{title} = $locale->text('Edit Credit Note');
-
- if ($form->{storno}) {
- $form->{title} = $locale->text('Edit Storno Credit Note');
- }
+ $form->{title} = $locale->text('Edit Storno Credit Note') if $form->{storno};
} else {
$form->{title} = $locale->text('Edit Sales Invoice');
-
- if ($form->{storno}) {
- $form->{title} = $locale->text('Edit Storno Invoice');
- }
+ $form->{title} = $locale->text('Edit Storno Invoice') if $form->{storno};
}
}
-
- $form->{radier} =
- ($form->current_date(\%myconfig) eq $form->{gldate}) ? 1 : 0;
+ $form->{defaultcurrency} = $form->get_default_currency(\%myconfig);
+ $form->{radier} = ($form->current_date(\%myconfig) eq $form->{gldate}) ? 1 : 0;
$payment = qq||;
foreach $item (@{ $form->{payment_terms} }) {
@@ -327,74 +302,113 @@ sub form_header {
}
}
- my $set_duedate_url =
- "$form->{script}?login=$form->{login}&path=$form->{path}&password=$form->{password}&action=set_duedate";
+ my $set_duedate_url = "$form->{script}?action=set_duedate";
my $pjx = new CGI::Ajax( 'set_duedate' => $set_duedate_url );
push(@ { $form->{AJAX} }, $pjx);
- 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/;
- }
+ my @old_project_ids = ($form->{"globalproject_id"});
+ map { push @old_project_ids, $form->{"project_id_$_"} if $form->{"project_id_$_"}; } 1..$form->{"rowcount"};
+
+ $form->get_lists("contacts" => "ALL_CONTACTS",
+ "shipto" => "ALL_SHIPTO",
+ "projects" => { "key" => "ALL_PROJECTS",
+ "all" => 0,
+ "old_id" => \@old_project_ids },
+ "employees" => "ALL_SALESMEN",
+ "taxzones" => "ALL_TAXZONES",
+ "currencies" => "ALL_CURRENCIES",
+ "customers" => "ALL_CUSTOMERS",
+ "price_factors" => "ALL_PRICE_FACTORS");
+
+ my %labels;
+ my @values = (undef);
+ foreach my $item (@{ $form->{"ALL_CONTACTS"} }) {
+ push(@values, $item->{"cp_id"});
+ $labels{$item->{"cp_id"}} = join(',', $item->{"cp_name"}, $item->{"cp_givenname"}) . ($item->{"cp_abteilung"} ? " ($item->{cp_abteilung})" : "");
+ }
+ my $contact;
+ if (scalar @values > 1) {
+ $contact = qq|
+
+ | . $locale->text('Contact Person') . qq| |
+ | . NTI($cgi->popup_menu('-name' => 'cp_id', '-values' => \@values, '-style' => 'width: 250px',
+ '-labels' => \%labels, '-default' => $form->{"cp_id"})) . qq|
+ |
+
|;
}
- $taxzone = qq|
-
- | . $locale->text('Steuersatz') . qq| |
- |
-
-
|;
+ %labels = ();
+ @values = ();
+ foreach my $item (@{ $form->{"ALL_SALESMEN"} }) {
+ push(@values, $item->{"id"});
+ $labels{$item->{id}} = $item->{name} ne "" ? $item->{name} : $item->{login};
+ }
- my @old_project_ids = ($form->{"globalproject_id"});
- map({ push(@old_project_ids, $form->{"project_id_$_"})
- if ($form->{"project_id_$_"}); } (1..$form->{"rowcount"}));
+ my $employees = qq|
+
+ | . $locale->text('Employee') . qq| |
+ | . NTI($cgi->popup_menu('-name' => 'employee_id', '-default' => $form->{"employee_id"},
+ '-values' => \@values, '-labels' => \%labels)) . qq|
+ |
+
|;
- $form->get_lists("contacts" => "ALL_CONTACTS",
- "shipto" => "ALL_SHIPTO",
- "projects" => { "key" => "ALL_PROJECTS",
- "all" => 0,
- "old_id" => \@old_project_ids },
- "employees" => "ALL_SALESMEN");
- my (%labels, @values);
- foreach my $item (@{ $form->{"ALL_CONTACTS"} }) {
- push(@values, $item->{"cp_id"});
- $labels{$item->{"cp_id"}} = $item->{"cp_name"} .
- ($item->{"cp_abteilung"} ? " ($item->{cp_abteilung})" : "");
+ %labels = ();
+ @values = ();
+ foreach my $item (@{ $form->{"ALL_CUSTOMERS"} }) {
+ push(@values, $item->{name}.qq|--|.$item->{"id"});
+ $labels{$item->{name}.qq|--|.$item->{"id"}} = $item->{"name"};
}
- my $contact =
- NTI($cgi->popup_menu('-name' => 'cp_id', '-values' => \@values,
- '-labels' => \%labels, '-default' => $form->{"cp_id"}));
+
+ $form->{selectcustomer} = ($myconfig{vclimit} > scalar(@values));
+
+ my $customers = qq|
+ | . $locale->text('Customer') . qq| |
+ | .
+ (($myconfig{vclimit} <= scalar(@values))
+ ? qq||
+ : (NTI($cgi->popup_menu('-name' => 'customer', '-default' => $form->{oldcustomer},
+ '-onChange' => 'document.getElementById(\'update_button\').click();',
+ '-values' => \@values, '-labels' => \%labels, '-style' => 'width: 250px')))) . qq|
+
+ | |;
%labels = ();
@values = ("");
foreach my $item (@{ $form->{"ALL_SHIPTO"} }) {
push(@values, $item->{"shipto_id"});
- $labels{$item->{"shipto_id"}} =
- $item->{"shiptoname"} . " " . $item->{"shiptodepartment_1"};
+ $labels{$item->{"shipto_id"}} = join "; ", grep { $_ } map { $item->{"shipto${_}" } } qw(name department_1 street city);
}
- my $shipto = qq|
- | . $locale->text('Shipping Address') . qq| |
- | .
- NTI($cgi->popup_menu('-name' => 'shipto_id', '-values' => \@values,
- '-labels' => \%labels, '-default' => $form->{"shipto_id"}))
- . qq| | |;
+ my $shipto;
+ if (scalar @values > 1) {
+ $shipto = qq|
+
+ | . $locale->text('Shipping Address') . qq| |
+ | . NTI($cgi->popup_menu('-name' => 'shipto_id', '-values' => \@values, '-style' => 'width: 250px',
+ '-labels' => \%labels, '-default' => $form->{"shipto_id"})). qq|
+ | |;
+ }
+
+ %labels = ();
+ @values = ();
+ foreach my $item (@{ $form->{"ALL_CURRENCIES"} }) {
+ push(@values, $item);
+ $labels{$item} = $item;
+ }
+
+ $form->{currency} = $form->{defaultcurrency} unless $form->{currency};
+ my $currencies;
+ if (scalar @values) {
+ $currencies = qq|
+
+ | . $locale->text('Currency') . qq| |
+ | . NTI($cgi->popup_menu('-name' => 'currency', '-default' => $form->{"currency"},
+ '-values' => \@values, '-labels' => \%labels)) . qq|
+ |
+
|;
+ }
%labels = ();
@values = ("");
@@ -402,79 +416,80 @@ sub form_header {
push(@values, $item->{"id"});
$labels{$item->{"id"}} = $item->{"projectnumber"};
}
- my $globalprojectnumber =
- NTI($cgi->popup_menu('-name' => 'globalproject_id', '-values' => \@values,
- '-labels' => \%labels,
- '-default' => $form->{"globalproject_id"}));
+ my $globalprojectnumber = NTI($cgi->popup_menu('-name' => 'globalproject_id', '-values' => \@values,
+ '-labels' => \%labels,
+ '-default' => $form->{"globalproject_id"}));
%labels = ();
- @values = ("");
+ @values = ();
foreach my $item (@{ $form->{ALL_SALESMEN} }) {
push(@values, $item->{id});
$labels{$item->{id}} = $item->{name} ne "" ? $item->{name} : $item->{login};
}
$salesman =
- qq|
- | . $locale->text('Salesman') . qq| |
- | .
- NTI($cgi->popup_menu('-name' => 'salesman_id', '-default' => $form->{salesman_id},
- '-values' => \@values, '-labels' => \%labels))
- . qq| |
-
|;
+ qq| | . $locale->text('Salesman') . qq| |
+ | . NTI($cgi->popup_menu('-name' => 'salesman_id', '-values' => \@values, '-labels' => \%labels,
+ '-default' => $form->{salesman_id} ? $form->{salesman_id} : $form->{employee_id})) . qq|
+ |
+
|;
- # set option selected
- foreach $item (qw(AR customer currency department employee)) {
- $form->{"select$item"} =~ s/ selected//;
- $form->{"select$item"} =~
- s/option>\Q$form->{$item}\E/option selected>$form->{$item}/;
+ %labels = ();
+ @values = ();
+ foreach my $item (@{ $form->{"ALL_TAXZONES"} }) {
+ push(@values, $item->{"id"});
+ $labels{$item->{"id"}} = $item->{"description"};
}
- #quote customer Bug 133
- $form->{selectcustomer} = $form->quote($form->{selectcustomer});
-
- if (($form->{creditlimit} != 0) && ($form->{creditremaining} < 0) && !$form->{update}) {
- $creditwarning = 1;
+ if (!$form->{"id"}) {
+ $taxzone = qq|
+
+ | . $locale->text('Steuersatz') . qq| |
+ | . NTI($cgi->popup_menu('-name' => 'taxzone_id', '-default' => $form->{"taxzone_id"},
+ '-values' => \@values, '-labels' => \%labels, '-style' => 'width: 250px',)) . qq|
+ |
+
|;
+
} else {
- $creditwarning = 0;
+ $taxzone = qq|
+
+ | . $locale->text('Steuersatz') . qq| |
+
+
+ | . H($labels{$form->{"taxzone_id"}}) . qq|
+ |
+
|;
}
- $form->{exchangerate} =
- $form->format_amount(\%myconfig, $form->{exchangerate});
+ # set option selected
+ foreach $item (qw(AR customer currency department employee)) {
+ $form->{"select$item"} =~ s/ selected//;
+ $form->{"select$item"} =~ s/option>\Q$form->{$item}\E/option selected>$form->{$item}/;
+ }
+
+ $creditwarning = (($form->{creditlimit} != 0) && ($form->{creditremaining} < 0) && !$form->{update}) ? 1 : 0;
- $form->{creditlimit} =
- $form->format_amount(\%myconfig, $form->{creditlimit}, 0, "0");
- $form->{creditremaining} =
- $form->format_amount(\%myconfig, $form->{creditremaining}, 0, "0");
+ $form->{exchangerate} = $form->format_amount(\%myconfig, $form->{exchangerate});
+ $form->{creditlimit} = $form->format_amount(\%myconfig, $form->{creditlimit}, 0, "0");
+ $form->{creditremaining} = $form->format_amount(\%myconfig, $form->{creditremaining}, 0, "0");
$exchangerate = "";
if ($form->{currency} ne $form->{defaultcurrency}) {
if ($form->{forex}) {
- $exchangerate .=
- qq||
- . $locale->text('Exchangerate')
- . qq| | $form->{exchangerate} | |;
+ $exchangerate .= qq|| . $locale->text('Exchangerate') . qq| |
+ $form->{exchangerate} | |;
} else {
- $exchangerate .=
- qq||
- . $locale->text('Exchangerate')
- . qq| | | |;
+ $exchangerate .= qq|| . $locale->text('Exchangerate') . qq| |
+ | |;
}
}
- $exchangerate .= qq|
-
-|;
-
- $customer =
- ($form->{selectcustomer})
- ? qq|\n|
- : qq||;
+ $exchangerate .= qq|\n\n|;
$department = qq|
| . $locale->text('Department') . qq| |
-
-
+ |
+
|
| if $form->{selectdepartment};
@@ -484,114 +499,84 @@ sub form_header {
if ($form->{business}) {
$business = qq|
- | . $locale->text('Business') . qq| |
- $form->{business} |
- | . $locale->text('Trade Discount') . qq| |
- |
+ | | . $locale->text('Customer type') . qq| |
+ $form->{business}; | . $locale->text('Trade Discount') . qq| |
. $form->format_amount(\%myconfig, $form->{tradediscount} * 100)
. qq| % |
-
+
|;
}
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| |
-
-
- |
-
+
+ | . $locale->text('Max. Dunning Level') . qq|: |
+
+ $form->{max_dunning_level};
+ | . $locale->text('Dunning Amount') . qq|: |
+ . $form->format_amount(\%myconfig, $form->{dunning_amount},2)
+ . qq|
+ |
+
|;
}
$form->{fokus} = "invoice.customer";
# use JavaScript Calendar or not
- $form->{jsscript} = $jscalendar;
+ $form->{jsscript} = 1;
$jsscript = "";
if ($form->{type} eq "credit_note") {
- if ($form->{jsscript}) {
-
- # with JavaScript Calendar
- $button1 = qq|
- |
- | |;
-
- #write Trigger
- $jsscript =
- Form->write_trigger(\%myconfig, "1",
- "invdate", "BL",
- "trigger1");
- } else {
-
- # without JavaScript Calendar
- $button1 =
- qq| | |;
- $button2 =
- qq| | |;
- }
+ $button1 = qq|
+
+ | |;
+
+ #write Trigger
+ $jsscript =
+ Form->write_trigger(\%myconfig, "1",
+ "invdate", "BL",
+ "trigger1");
} else {
- if ($form->{jsscript}) {
-
- # with JavaScript Calendar
- $button1 = qq|
- |
- |
- |;
- $button2 = qq|
- |
- |
+ $button1 = qq|
+
+ |
|;
- $button3 = qq|
- |
- |
- |;
-
- #write Trigger
- $jsscript =
- Form->write_trigger(\%myconfig, "3",
- "invdate", "BL",
- "trigger1", "duedate",
- "BL", "trigger2",
- "deliverydate", "BL",
- "trigger3");
- } else {
-
- # without JavaScript Calendar
- $button1 =
- qq| | |;
- $button2 =
- qq|{duedate}> | |;
- }
- }
- 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()";
+ $button2 = qq|
+
+ |
+ |;
+ $button3 = qq|
+
+ |
+ |;
+
+ #write Trigger
+ $jsscript =
+ Form->write_trigger(\%myconfig, "3",
+ "invdate", "BL", "trigger1",
+ "duedate", "BL", "trigger2",
+ "deliverydate", "BL", "trigger3");
}
$credittext = $locale->text('Credit Limit exceeded!!!');
- if ($creditwarning) {
- $onload = qq|alert('$credittext')|;
- }
- $form->{"javascript"} .= qq||;
+ my $follow_up_vc = $form->{customer};
+ $follow_up_vc =~ s/--.*?//;
+ my $follow_up_trans_info = "$form->{invnumber} ($follow_up_vc)";
+
+ $onload = ($form->{resubmit} && ($form->{format} eq "html")) ? qq|window.open('about:blank','Beleg'); document.invoice.target = 'Beleg';document.invoice.submit()|
+ : ($form->{resubmit}) ? qq|document.invoice.submit()|
+ : ($creditwarning) ? qq|alert('$credittext')|
+ : "focus()";
+ $onload .= qq|;setupDateFormat('|. $myconfig{dateformat} .qq|', '|. $locale->text("Falsches Datumsformat!") .qq|')|;
+ $onload .= qq|;setupPoints('|. $myconfig{numberformat} .qq|', '|. $locale->text("wrongformat") .qq|')|;
+
+ $form->{javascript} .= qq||;
+ $form->{javascript} .= qq||;
$jsscript .=
$form->write_trigger(\%myconfig, 2,
@@ -608,67 +593,60 @@ sub form_header {
+