X-Git-Url: http://wagnertech.de/git?a=blobdiff_plain;ds=sidebyside;f=bin%2Fmozilla%2Far.pl;h=f5ea6c429a62aa61a6e43b3bb5b9866b94759b46;hb=4f97d578f0ea0104fcd5cc63ed96622d89f6fceb;hp=2f2f55e56ab4139503bfa600ddfa486b28a00423;hpb=e87f4016fbce09fc32b3b7ca18b78f364ad6ee6f;p=kivitendo-erp.git
diff --git a/bin/mozilla/ar.pl b/bin/mozilla/ar.pl
index 2f2f55e56..f5ea6c429 100644
--- a/bin/mozilla/ar.pl
+++ b/bin/mozilla/ar.pl
@@ -32,12 +32,13 @@
#======================================================================
use POSIX qw(strftime);
-use List::Util qw(sum first);
+use List::Util qw(sum first max);
use SL::AR;
use SL::FU;
use SL::IS;
use SL::PE;
+use SL::DB::Default;
use SL::ReportGenerator;
require "bin/mozilla/arap.pl";
@@ -99,7 +100,7 @@ sub add {
AR->get_transdate(\%myconfig, $form);
$form->{initial_transdate} = $form->{transdate};
- &create_links;
+ create_links(dont_save => 1);
$form->{transdate} = $form->{initial_transdate};
&display_form;
$main::lxdebug->leave_sub();
@@ -118,7 +119,7 @@ sub edit {
$form->{javascript} .= qq||;
$form->{title} = "Edit";
- &create_links;
+ create_links();
&display_form;
$main::lxdebug->leave_sub();
@@ -142,27 +143,24 @@ sub create_links {
$main::auth->assert('general_ledger');
+ my %params = @_;
my $form = $main::form;
my %myconfig = %main::myconfig;
- my ($duedate, $taxincluded);
-
$form->create_links("AR", \%myconfig, "customer");
- $duedate = $form->{duedate};
- $taxincluded = $form->{taxincluded};
- my $id = $form->{id};
+ my %saved;
+ if (!$params{dont_save}) {
+ %saved = map { ($_ => $form->{$_}) } qw(direct_debit id taxincluded);
+ $saved{duedate} = $form->{duedate} if $form->{duedate};
+ }
+
IS->get_customer(\%myconfig, \%$form);
- $form->{taxincluded} = $taxincluded;
- $form->{id} = $id;
- $form->{duedate} = $duedate if $duedate;
+ $form->{$_} = $saved{$_} for keys %saved;
$form->{oldcustomer} = "$form->{customer}--$form->{customer_id}";
$form->{rowcount} = 1;
- # notes
- $form->{notes} = $form->{intnotes} unless $form->{notes};
-
# currencies
$form->{defaultcurrency} = $form->get_default_currency(\%myconfig);
@@ -215,22 +213,18 @@ sub form_header {
my $form = $main::form;
my %myconfig = %main::myconfig;
my $locale = $main::locale;
- my $cgi = $main::cgi;
+ my $cgi = $::request->{cgi};
my ($title, $readonly, $exchangerate, $rows);
- my ($taxincluded, $notes, $department, $customer, $employee, $amount, $project);
- my ($jsscript, $button1, $button2, $onload);
- my ($selectAR_amount, $selectAR_paid, $ARselected, $tax);
- my (@column_index, %column_data);
+ my ($notes, $department, $customer, $employee, $amount, $project);
+ my ($ARselected);
$title = $form->{title};
- $form->{title} = $locale->text("$title Accounts Receivables Transaction");
-
- $form->{taxincluded} = ($form->{taxincluded}) ? "checked" : "";
-
# $locale->text('Add Accounts Receivables Transaction')
# $locale->text('Edit Accounts Receivables Transaction')
+ $form->{title} = $locale->text("$title Accounts Receivables Transaction");
+
$form->{javascript} = qq||;
#/show history button js
- $form->{javascript} .= qq||;
$readonly = ($form->{id}) ? "readonly" : "";
- $form->{radier} =
- ($form->current_date(\%myconfig) eq $form->{gldate}) ? 1 : 0;
+ $form->{radier} = ($::instance_conf->get_ar_changeable == 2)
+ ? ($form->current_date(\%myconfig) eq $form->{gldate})
+ : ($::instance_conf->get_ar_changeable == 1);
$readonly = ($form->{radier}) ? "" : $readonly;
# set option selected
foreach my $item (qw(customer currency department employee)) {
$form->{"select$item"} =~ s/ selected//;
- $form->{"select$item"} =~
- s/option>\Q$form->{$item}\E/option selected>$form->{$item}/;
+ $form->{"select$item"} =~ s/option>\Q$form->{$item}\E/option selected>$form->{$item}/;
}
$form->{forex} = $form->check_exchangerate( \%myconfig, $form->{currency}, $form->{transdate}, 'buy');
$form->{exchangerate} = $form->{forex} if $form->{forex};
- # format amounts
- $form->{exchangerate} = $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 = qq|
-{forex}>
-|;
- if ($form->{defaultcurrency} && ($form->{currency} ne $form->{defaultcurrency})) {
- if ($form->{forex}) {
- $exchangerate .= qq|
-
| . $locale->text('Exchangerate') . qq| |
- {exchangerate}>$form->{exchangerate} |
-|;
- } else {
- $exchangerate .= qq|
- | . $locale->text('Exchangerate') . qq| |
- {exchangerate}> |
-|;
- }
- }
-
- $taxincluded = qq|
-
- {taxincluded}> |
- | . $locale->text('Tax Included') . qq| |
-
-|;
+ $rows = max 2, $form->numtextrows($form->{notes}, 50);
- if (($rows = $form->numtextrows($form->{notes}, 50)) < 2) {
- $rows = 2;
- }
- $notes =
- qq||;
-
- $department = qq|
-
- | . $locale->text('Department') . qq| |
-
-
- |
-
-| if $form->{selectdepartment};
-
- my $n = ($form->{creditremaining} =~ /-/) ? "0" : "1";
-
- $customer = ($form->{selectcustomer})
- ? qq||
- : qq||;
-
- $employee = qq|
-
-|;
-
- if ($form->{selectemployee}) {
- $employee = qq|
-
- | . $locale->text('Salesperson') . qq| |
- |
-
-
-|;
- }
-
- my @old_project_ids = ();
- map({ push(@old_project_ids, $form->{"project_id_$_"})
- if ($form->{"project_id_$_"}); } (1..$form->{"rowcount"}));
+ my @old_project_ids = grep { $_ } map { $form->{"project_id_$_"} } 1..$form->{rowcount};
$form->get_lists("projects" => { "key" => "ALL_PROJECTS",
"all" => 0,
@@ -346,40 +275,32 @@ sub form_header {
"taxcharts" => { "key" => "ALL_TAXCHARTS",
"module" => "AR" },);
- map({ $_->{link_split} = [ split(/:/, $_->{link}) ]; }
- @{ $form->{ALL_CHARTS} });
+ $_->{link_split} = { map { $_ => 1 } split/:/, $_->{link} } for @{ $form->{ALL_CHARTS} };
- my %project_labels = ();
- my @project_values = ("");
- foreach my $item (@{ $form->{"ALL_PROJECTS"} }) {
- push(@project_values, $item->{"id"});
- $project_labels{$item->{"id"}} = $item->{"projectnumber"};
- }
+ my %project_labels = map { $_->{id} => $_->{projectnumber} } @{ $form->{"ALL_PROJECTS"} };
- my (%AR_amount_labels, @AR_amount_values);
- my (%AR_labels, @AR_values);
- my (%AR_paid_labels, @AR_paid_values);
+ my (@AR_amount_values);
+ my (@AR_values);
+ my (@AR_paid_values);
+ my %chart_labels;
my %charts;
my $taxchart_init;
foreach my $item (@{ $form->{ALL_CHARTS} }) {
- if (grep({ $_ eq "AR_amount" } @{ $item->{link_split} })) {
+ if ($item->{link_split}{AR_amount}) {
$taxchart_init = $item->{tax_id} if ($taxchart_init eq "");
my $key = "$item->{accno}--$item->{tax_id}";
push(@AR_amount_values, $key);
- $AR_amount_labels{$key} =
- "$item->{accno}--$item->{description}";
-
- } elsif (grep({ $_ eq "AR" } @{ $item->{link_split} })) {
+ } elsif ($item->{link_split}{AR}) {
push(@AR_values, $item->{accno});
- $AR_labels{$item->{accno}} = "$item->{accno}--$item->{description}";
-
- } elsif (grep({ $_ eq "AR_paid" } @{ $item->{link_split} })) {
+ } elsif ($item->{link_split}{AR_paid}) {
push(@AR_paid_values, $item->{accno});
- $AR_paid_labels{$item->{accno}} =
- "$item->{accno}--$item->{description}";
}
+ # weirdness for AR_amount
+ $chart_labels{$item->{accno}} = "$item->{accno}--$item->{description}";
+ $chart_labels{"$item->{accno}--$item->{tax_id}"} = "$item->{accno}--$item->{description}";
+
$charts{$item->{accno}} = $item;
}
@@ -390,184 +311,30 @@ sub form_header {
my $key = "$item->{id}--$item->{rate}";
$taxchart_init = $key if ($taxchart_init eq $item->{id});
push(@taxchart_values, $key);
- $taxchart_labels{$key} =
- "$item->{taxdescription} " . ($item->{rate} * 100) . ' %';
+ $taxchart_labels{$key} = "$item->{taxdescription} " . ($item->{rate} * 100) . ' %';
$taxcharts{$item->{id}} = $item;
}
- $form->{fokus} = "arledger.customer";
-
- # use JavaScript Calendar or not
- $form->{jsscript} = 1;
- $jsscript = "";
- if ($form->{jsscript}) {
-
- # with JavaScript Calendar
- $button1 = qq|
- |
- text('button') . qq|> |
- |;
- $button2 = qq|
- |
- text('button') . qq|> |
- |;
-
- #write Trigger
- $jsscript =
- Form->write_trigger(\%myconfig, "2", "transdate", "BL", "trigger1",
- "duedate", "BL", "trigger2");
- } else {
-
- # without JavaScript Calendar
- $button1 =
- qq| | |;
- $button2 =
- qq| | |;
- }
+ $::request->{layout}->focus("#customer");
my $follow_up_vc = $form->{customer};
$follow_up_vc =~ s/--.*?//;
my $follow_up_trans_info = "$form->{invnumber} ($follow_up_vc)";
$form->{javascript} .=
- qq|| .
qq|| .
qq||;
- my $globalprojectnumber =
- NTI($cgi->popup_menu('-name' => "globalproject_id",
- '-values' => \@project_values,
- '-labels' => \%project_labels,
- '-default' => $form->{"globalproject_id"} ));
-
- $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|
-
-
-
+ $form->{show_mark_as_paid_button} = $form->{id} && $::instance_conf->get_ar_show_mark_as_paid();
-
-