X-Git-Url: http://wagnertech.de/git?a=blobdiff_plain;ds=inline;f=bin%2Fmozilla%2Fis.pl;h=9bc225e884bb596231ed4b64ad7441710820be02;hb=1043d7f814fccf5864e677b1e38577d0a150026c;hp=992235701e8fb877d995c063e5192f17b3f51925;hpb=fb4d2ffa6aae03b36e4db77be10c3d9dce4413f8;p=kivitendo-erp.git
diff --git a/bin/mozilla/is.pl b/bin/mozilla/is.pl
index 992235701..9bc225e88 100644
--- a/bin/mozilla/is.pl
+++ b/bin/mozilla/is.pl
@@ -31,11 +31,14 @@
#
#======================================================================
+use SL::FU;
use SL::IS;
use SL::PE;
use Data::Dumper;
+use List::Util qw(max sum);
require "bin/mozilla/io.pl";
+require "bin/mozilla/invoice_io.pl";
require "bin/mozilla/arap.pl";
require "bin/mozilla/drafts.pl";
@@ -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}&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
@@ -169,11 +168,6 @@ sub invoice_links {
$form->{oldcustomer} = "$form->{customer}--$form->{customer_id}";
- if (@{ $form->{all_customer} }) {
- $form->{customer} = "$form->{customer}--$form->{customer_id}";
- $form->{selectcustomer} = "$form->{customer}--$form->{customer_id}";
- }
-
# departments
if ($form->{all_departments}) {
$form->{selectdepartment} = "|;
foreach $item (@{ $form->{payment_terms} }) {
@@ -313,42 +302,38 @@ sub form_header {
}
}
- my $set_duedate_url =
- "$form->{script}?login=$form->{login}&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);
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");
+ 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"}} = $item->{"cp_name"} .
- ($item->{"cp_abteilung"} ? " ($item->{cp_abteilung})" : "");
+ $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,
- '-labels' => \%labels, '-default' => $form->{"cp_id"}))
- . qq|
+ | | . NTI($cgi->popup_menu('-name' => 'cp_id', '-values' => \@values, '-style' => 'width: 250px',
+ '-labels' => \%labels, '-default' => $form->{"cp_id"})) . qq|
|
|;
}
@@ -357,15 +342,14 @@ sub form_header {
@values = ();
foreach my $item (@{ $form->{"ALL_SALESMEN"} }) {
push(@values, $item->{"id"});
- $labels{$item->{"id"}} = $item->{"name"};
+ $labels{$item->{id}} = $item->{name} ne "" ? $item->{name} : $item->{login};
}
my $employees = qq|
| . $locale->text('Employee') . qq| |
- | .
- NTI($cgi->popup_menu('-name' => 'employee', '-default' => $form->{"employee_id"},
- '-values' => \@values, '-labels' => \%labels)) . qq|
+ | | . NTI($cgi->popup_menu('-name' => 'employee_id', '-default' => $form->{"employee_id"},
+ '-values' => \@values, '-labels' => \%labels)) . qq|
|
|;
@@ -374,26 +358,27 @@ sub form_header {
@values = ();
foreach my $item (@{ $form->{"ALL_CUSTOMERS"} }) {
push(@values, $item->{name}.qq|--|.$item->{"id"});
- $labels{$item->{"id"}} = $item->{name}.qq|--|.$item->{"id"};
+ $labels{$item->{name}.qq|--|.$item->{"id"}} = $item->{"name"};
}
+ $form->{selectcustomer} = ($myconfig{vclimit} > scalar(@values));
+
my $customers = qq|
| . $locale->text('Customer') . qq| |
| .
(($myconfig{vclimit} <= scalar(@values))
- ? qq||
+ ? qq||
: (NTI($cgi->popup_menu('-name' => 'customer', '-default' => $form->{oldcustomer},
'-onChange' => 'document.getElementById(\'update_button\').click();',
- '-values' => \@values, '-labels' => \%labels)))) . qq|
-
+ '-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;
@@ -401,10 +386,9 @@ sub form_header {
$shipto = qq|
| . $locale->text('Shipping Address') . qq| |
- | .
- NTI($cgi->popup_menu('-name' => 'shipto_id', '-values' => \@values,
- '-labels' => \%labels, '-default' => $form->{"shipto_id"}))
- . qq| | |;
+ | . NTI($cgi->popup_menu('-name' => 'shipto_id', '-values' => \@values, '-style' => 'width: 250px',
+ '-labels' => \%labels, '-default' => $form->{"shipto_id"})). qq|
+ | |;
}
%labels = ();
@@ -420,9 +404,8 @@ sub form_header {
$currencies = qq|
| . $locale->text('Currency') . qq| |
- | .
- NTI($cgi->popup_menu('-name' => 'currency', '-default' => $form->{"currency"},
- '-values' => \@values, '-labels' => \%labels)) . qq|
+ | | . NTI($cgi->popup_menu('-name' => 'currency', '-default' => $form->{"currency"},
+ '-values' => \@values, '-labels' => \%labels)) . qq|
|
|;
}
@@ -433,26 +416,23 @@ 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|
+ |
+
|;
%labels = ();
@values = ();
@@ -465,9 +445,8 @@ sub form_header {
$taxzone = qq|
| . $locale->text('Steuersatz') . qq| |
- | .
- NTI($cgi->popup_menu('-name' => 'taxzone_id', '-default' => $form->{"taxzone_id"},
- '-values' => \@values, '-labels' => \%labels)) . qq|
+ | | . NTI($cgi->popup_menu('-name' => 'taxzone_id', '-default' => $form->{"taxzone_id"},
+ '-values' => \@values, '-labels' => \%labels, '-style' => 'width: 250px',)) . qq|
|
|;
@@ -485,53 +464,32 @@ sub form_header {
# 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}/;
- }
-
- #quote customer Bug 133
- $form->{selectcustomer} = $form->quote($form->{selectcustomer});
-
- #substitute \n and \r to \s (bug 543)
- $form->{selectcustomer} =~ s/[\n\r]/ /g;
-
- if (($form->{creditlimit} != 0) && ($form->{creditremaining} < 0) && !$form->{update}) {
- $creditwarning = 1;
- } else {
- $creditwarning = 0;
+ $form->{"select$item"} =~ s/option>\Q$form->{$item}\E/option selected>$form->{$item}/;
}
- $form->{exchangerate} =
- $form->format_amount(\%myconfig, $form->{exchangerate});
+ $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|
-
-|;
+ $exchangerate .= qq|\n\n|;
$department = qq|
| . $locale->text('Department') . qq| |
-
-
+ |
+
|
| if $form->{selectdepartment};
@@ -541,13 +499,11 @@ 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| % |
-
+
|;
}
@@ -572,8 +528,8 @@ sub form_header {
$jsscript = "";
if ($form->{type} eq "credit_note") {
$button1 = qq|
-
-
+ | |;
#write Trigger
@@ -583,48 +539,44 @@ sub form_header {
"trigger1");
} else {
$button1 = qq|
-
-
+ |
|;
$button2 = qq|
- |
+
|;
$button3 = qq|
- |
+
|;
#write Trigger
$jsscript =
Form->write_trigger(\%myconfig, "3",
- "invdate", "BL",
- "trigger1", "duedate",
- "BL", "trigger2",
- "deliverydate", "BL",
- "trigger3");
+ "invdate", "BL", "trigger1",
+ "duedate", "BL", "trigger2",
+ "deliverydate", "BL", "trigger3");
}
- 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 = "focus()";
- }
+ $credittext = $locale->text('Credit Limit exceeded!!!');
+
+ my $follow_up_vc = $form->{customer};
+ $follow_up_vc =~ s/--\d*\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|')|;
- $credittext = $locale->text('Credit Limit exceeded!!!');
- if ($creditwarning) {
- $onload = qq|alert('$credittext')|;
- }
- $form->{"javascript"} .= qq||;
- $form->{javascript} .= qq||;
+ $form->{javascript} .= qq||;
+ $form->{javascript} .= qq||;
$jsscript .=
$form->write_trigger(\%myconfig, 2,
@@ -641,14 +593,27 @@ sub form_header {
+