X-Git-Url: http://wagnertech.de/git?a=blobdiff_plain;ds=sidebyside;f=bin%2Fmozilla%2Fir.pl;h=ced248f4807b6a2f046461ad63db6dbbe9f5ca4d;hb=03c526b3b946d62f95ce78420552d62b39e03bed;hp=f4345c1fe1cf3dc549a6531fee8638aae2b47e7b;hpb=b6dc5623d93c1be1c54248d4512e80f495af2899;p=kivitendo-erp.git
diff --git a/bin/mozilla/ir.pl b/bin/mozilla/ir.pl
index f4345c1fe..ced248f48 100644
--- a/bin/mozilla/ir.pl
+++ b/bin/mozilla/ir.pl
@@ -31,10 +31,11 @@
#
#======================================================================
+use SL::FU;
use SL::IR;
use SL::IS;
use SL::PE;
-use List::Util qw(max);
+use List::Util qw(max sum);
require "bin/mozilla/io.pl";
require "bin/mozilla/invoice_io.pl";
@@ -42,51 +43,70 @@ require "bin/mozilla/arap.pl";
require "bin/mozilla/common.pl";
require "bin/mozilla/drafts.pl";
+use strict;
+
1;
# end of main
sub add {
- $lxdebug->enter_sub();
+ $main::lxdebug->enter_sub();
+
+ my $form = $main::form;
+ my $locale = $main::locale;
+
+ $main::auth->assert('vendor_invoice_edit');
- return $lxdebug->leave_sub() if (load_draft_maybe());
+ return $main::lxdebug->leave_sub() if (load_draft_maybe());
- $form->{title} = $locale->text('Add Vendor Invoice');
+ $form->{title} = $locale->text('Record Vendor Invoice');
&invoice_links;
&prepare_invoice;
&display_form;
- $lxdebug->leave_sub();
+ $main::lxdebug->leave_sub();
}
sub edit {
- $lxdebug->enter_sub();
+ $main::lxdebug->enter_sub();
+
+ my $form = $main::form;
+ my $locale = $main::locale;
+
+ $main::auth->assert('vendor_invoice_edit');
# show history button
$form->{javascript} = qq||;
#/show hhistory button
-
+
$form->{title} = $locale->text('Edit Vendor Invoice');
&invoice_links;
&prepare_invoice;
&display_form;
- $lxdebug->leave_sub();
+ $main::lxdebug->leave_sub();
}
sub invoice_links {
- $lxdebug->enter_sub();
+ $main::lxdebug->enter_sub();
+
+ my $form = $main::form;
+ my %myconfig = %main::myconfig;
+
+ $main::auth->assert('vendor_invoice_edit');
+
+ $form->{vc} = 'vendor';
# create links
- $form->{webdav} = $webdav;
+ $form->{webdav} = $main::webdav;
$form->{jsscript} = 1;
$form->create_links("AP", \%myconfig, "vendor");
#quote all_vendor Bug 133
- foreach $ref (@{ $form->{all_vendor} }) {
+ foreach my $ref (@{ $form->{all_vendor} }) {
$ref->{name} = $form->quote($ref->{name});
}
@@ -95,6 +115,8 @@ sub invoice_links {
$form->{vendor_id} = $form->{all_vendor}->[0]->{id};
}
}
+
+ my ($payment_id, $language_id, $taxzone_id);
if ($form->{payment_id}) {
$payment_id = $form->{payment_id};
}
@@ -105,11 +127,11 @@ sub invoice_links {
$taxzone_id = $form->{taxzone_id};
}
- $cp_id = $form->{cp_id};
+ my $cp_id = $form->{cp_id};
IR->get_vendor(\%myconfig, \%$form);
IR->retrieve_invoice(\%myconfig, \%$form);
$form->{cp_id} = $cp_id;
-
+
if ($payment_id) {
$form->{payment_id} = $payment_id;
}
@@ -120,10 +142,17 @@ sub invoice_links {
$form->{taxzone_id} = $taxzone_id;
}
+ my @curr = split(/:/, $form->{currencies}); #seems to be missing
map { $form->{selectcurrency} .= "";
}
+ next unless $form->{acc_trans}{$key};
+
if ($key eq "AP_paid") {
- for $i (1 .. scalar @{ $form->{acc_trans}{$key} }) {
+ for my $i (1 .. scalar @{ $form->{acc_trans}{$key} }) {
$form->{"AP_paid_$i"} =
"$form->{acc_trans}{$key}->[$i-1]->{accno}--$form->{acc_trans}{$key}->[$i-1]->{description}";
@@ -176,24 +207,29 @@ sub invoice_links {
($form->datetonum($form->{invdate}, \%myconfig) <=
$form->datetonum($form->{closedto}, \%myconfig));
- $lxdebug->leave_sub();
+ $main::lxdebug->leave_sub();
}
sub prepare_invoice {
- $lxdebug->enter_sub();
+ $main::lxdebug->enter_sub();
+
+ my $form = $main::form;
+ my %myconfig = %main::myconfig;
+
+ $main::auth->assert('vendor_invoice_edit');
if ($form->{id}) {
map { $form->{$_} =~ s/\"/"/g } qw(invnumber ordnumber quonumber);
my $i = 0;
- foreach $ref (@{ $form->{invoice_details} }) {
+ foreach my $ref (@{ $form->{invoice_details} }) {
$i++;
map { $form->{"${_}_$i"} = $ref->{$_} } keys %{$ref};
- ($dec) = ($form->{"sellprice_$i"} =~ /\.(\d+)/);
+ my ($dec) = ($form->{"sellprice_$i"} =~ /\.(\d+)/);
$dec = length $dec;
- $decimalplaces = ($dec > 2) ? $dec : 2;
+ my $decimalplaces = ($dec > 2) ? $dec : 2;
$form->{"sellprice_$i"} =
$form->format_amount(\%myconfig, $form->{"sellprice_$i"},
@@ -209,660 +245,218 @@ sub prepare_invoice {
}
}
- $lxdebug->leave_sub();
+ $main::lxdebug->leave_sub();
}
sub form_header {
- $lxdebug->enter_sub();
+ $main::lxdebug->enter_sub();
- # set option selected
- foreach $item (qw(AP vendor currency department)) {
- $form->{"select$item"} =~ s/ selected//;
- $form->{"select$item"} =~ s/option>\Q$form->{$item}\E/option selected>$form->{$item}/;
- }
+ my $form = $main::form;
+ my %myconfig = %main::myconfig;
+ my $locale = $main::locale;
+ my $cgi = $main::cgi;
+
+ $main::auth->assert('invoice_edit');
+
+ my %TMPL_VAR = ();
+ my @custom_hiddens;
+
+ $form->{employee_id} = $form->{old_employee_id} if $form->{old_employee_id};
+ $form->{salesman_id} = $form->{old_salesman_id} if $form->{old_salesman_id};
- $form->{employee_id} = $form->{old_employee_id} if $form->{old_employee_id};
- $form->{salesman_id} = $form->{old_salesman_id} if $form->{old_salesman_id};
$form->{defaultcurrency} = $form->get_default_currency(\%myconfig);
- $form->{radier} = ($form->current_date(\%myconfig) eq $form->{gldate}) ? 1 : 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}> | \n|;
- } else {
- $exchangerate .= qq| | . $locale->text('Exchangerate') . qq| |
- {exchangerate}> | \n|;
- }
- }
- $exchangerate .= qq| {forex}>\n|;
+
+ my $set_duedate_url = "$form->{script}?action=set_duedate";
+
+ push @ { $form->{AJAX} }, new CGI::Ajax( 'set_duedate' => $set_duedate_url );
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",
- "projects" => { "key" => "ALL_PROJECTS",
- "all" => 0,
- "old_id" => \@old_project_ids },
+ "shipto" => "ALL_SHIPTO",
+ "projects" => { "key" => "ALL_PROJECTS",
+ "all" => 0,
+ "old_id" => \@old_project_ids },
+ "employees" => "ALL_EMPLOYEES",
"taxzones" => "ALL_TAXZONES",
- "employees" => "ALL_SALESMEN",
"currencies" => "ALL_CURRENCIES",
"vendors" => "ALL_VENDORS",
+ "departments" => "all_departments",
"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})" : "");
- }
-
- 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|
- |
-
|;
- }
-
- %labels = ();
- @values = ("");
- foreach my $item (@{ $form->{"ALL_PROJECTS"} }) {
- 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"}));
-
- %labels = ();
- @values = ();
- my $i = 0;
- 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 = ();
- my $i = 0;
- foreach my $item (@{ $form->{"ALL_SALESMEN"} }) {
- push(@values, $item->{"id"});
- $labels{$item->{"id"}} = $item->{"name"};
- }
- my $employees = qq|
-
- | . $locale->text('Employee') . qq| |
- | . NTI($cgi->popup_menu('-name' => 'employee_id', '-default' => $form->{"employee_id"},
- '-values' => \@values, '-labels' => \%labels)) . qq|
- |
-
|;
-
- %labels = ();
- @values = ();
- my $i = 0;
- foreach my $item (@{ $form->{"ALL_VENDORS"} }) {
- push(@values, $item->{name}.qq|--|.$item->{"id"});
- $labels{$item->{name}.qq|--|.$item->{"id"}} = $item->{"name"};
- }
-
- $form->{selectvendor} = ($myconfig{vclimit} > scalar(@values));
-
- my $vendors = qq|
- | . $locale->text('Vendor') . qq| |
- | .
- (($myconfig{vclimit} <= scalar(@values))
- ? qq||
- : (NTI($cgi->popup_menu('-name' => 'vendor', '-default' => $form->{oldvendor},
- '-onChange' => 'document.getElementById(\'update_button\').click();',
- '-values' => \@values, '-labels' => \%labels, '-style' => 'width: 250px')))) . qq|
-
- | |;
-
- %labels = ();
- @values = ();
- foreach my $item (@{ $form->{"ALL_TAXZONES"} }) {
- push(@values, $item->{"id"});
- $labels{$item->{"id"}} = $item->{"description"};
- }
-
- 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 {
- $taxzone = qq|
-
- | . $locale->text('Steuersatz') . qq| |
-
-
- | . H($labels{$form->{"taxzone_id"}}) . qq|
- |
-
|;
+ $TMPL_VAR{sales_employee_labels} = sub { $_[0]->{name} || $_[0]->{login} };
+# $TMPL_VAR{shipto_labels} = sub { join "; ", grep { $_ } map { $_[0]->{"shipto${_}" } } qw(name department_1 street city) };
+ $TMPL_VAR{contact_labels} = sub { join(', ', $_[0]->{"cp_name"}, $_[0]->{"cp_givenname"}) . ($_[0]->{cp_abteilung} ? " ($_[0]->{cp_abteilung})" : "") };
+ $TMPL_VAR{department_labels} = sub { "$_[0]->{description}--$_[0]->{id}" };
+
+ # customer
+ $TMPL_VAR{vc_keys} = sub { "$_[0]->{name}--$_[0]->{id}" };
+ $TMPL_VAR{vclimit} = $myconfig{vclimit};
+ $TMPL_VAR{vc_select} = "customer_or_vendor_selection_window('vendor', '', 1, 0)";
+ push @custom_hiddens, "vendor_id";
+ push @custom_hiddens, "oldvendor";
+ push @custom_hiddens, "selectvendor";
+
+ # currencies and exchangerate
+ my @values = map { $_ } @{ $form->{ALL_CURRENCIES} };
+ my %labels = map { $_ => $_ } @{ $form->{ALL_CURRENCIES} };
+ $form->{currency} = $form->{defaultcurrency} unless $form->{currency};
+ $TMPL_VAR{show_exchangerate} = $form->{currency} ne $form->{defaultcurrency};
+ $TMPL_VAR{currencies} = NTI($cgi->popup_menu('-name' => 'currency', '-default' => $form->{"currency"},
+ '-values' => \@values, '-labels' => \%labels)) if scalar @values;
+ push @custom_hiddens, "forex";
+ push @custom_hiddens, "exchangerate" if $form->{forex};
+
+ $TMPL_VAR{creditwarning} = ($form->{creditlimit} != 0) && ($form->{creditremaining} < 0) && !$form->{update};
+ $TMPL_VAR{is_credit_remaining_negativ} = $form->{creditremaining} =~ /-/;
+
+ $form->{fokus} = "invoice.vendor";
+
+ my $follow_up_vc = $form->{vendor};
+ $follow_up_vc =~ s/--\d*\s*$//;
+ $TMPL_VAR{vendor_name} = $follow_up_vc;
+
+# set option selected
+ foreach my $item (qw(AP)) {
+ $form->{"select$item"} =~ s/ selected//;
+ $form->{"select$item"} =~ s/option>\Q$form->{$item}\E/option selected>$form->{$item}/;
}
- $department = qq|
-
- | . $locale->text('Department') . qq| |
-
-
- |
-
\n| if $form->{selectdepartment};
+ $TMPL_VAR{is_type_credit_note} = $form->{type} eq "credit_note";
+ $TMPL_VAR{is_format_html} = $form->{format} eq 'html';
+ $TMPL_VAR{dateformat} = $myconfig{dateformat};
+ $TMPL_VAR{numberformat} = $myconfig{numberformat};
- $n = ($form->{creditremaining} =~ /-/) ? "0" : "1";
+ # hiddens
+ $TMPL_VAR{HIDDENS} = [qw(
+ id action type media format queued printed emailed title vc discount
+ title creditlimit creditremaining tradediscount business closedto locked shipped storno storno_id
+ max_dunning_level dunning_amount
+ shiptoname shiptostreet shiptozipcode shiptocity shiptocountry shiptocontact shiptophone shiptofax
+ shiptoemail shiptodepartment_1 shiptodepartment_2 message email subject cc bcc taxaccounts cursor_fokus
+ convert_from_do_ids convert_from_oe_ids
+ ), @custom_hiddens,
+ map { $_.'_rate', $_.'_description', $_.'_taxnumber' } split / /, $form->{taxaccounts}];
- # use JavaScript Calendar or not
$form->{jsscript} = 1;
- $jsscript = "";
+ $form->header();
- $button1 = qq|
-
- text('button') . qq|> | \n|;
- $button2 = qq|
-
- text('button') . qq|> | \n|;
+ print $form->parse_html_template("ir/form_header", \%TMPL_VAR);
- #write Trigger
- $jsscript =
- Form->write_trigger(\%myconfig, "2",
- "invdate", "BL", "trigger1",
- "duedate", "BL", "trigger2");
-
- $form->{javascript} .= qq||;
- $form->{javascript} .= qq||;
- $form->{javascript} .= qq||;
-
- $jsscript .= $form->write_trigger(\%myconfig, 2, "orddate", "BL", "trigger_orddate", "quodate", "BL", "trigger_quodate");
-
- $form->header;
- $onload = qq|focus()|;
- $onload .= qq|;setupDateFormat('|. $myconfig{dateformat} .qq|', '|. $locale->text("Falsches Datumsformat!") .qq|')|;
- $onload .= qq|;setupPoints('|. $myconfig{numberformat} .qq|', '|. $locale->text("wrongformat") .qq|')|;
- print qq|
-
-
-
+ $main::auth->assert('vendor_invoice_edit');
-
-