$form->{title} |
@@ -505,9 +574,6 @@ sub form_header {
$jsscript
-
-
-
{rowcount}>
@@ -537,28 +603,61 @@ $jsscript
$form->{"amount_$i"} =
$form->format_amount(\%myconfig, $form->{"amount_$i"}, 2);
$form->{"tax_$i"} = $form->format_amount(\%myconfig, $form->{"tax_$i"}, 2);
- $selectAP_amount = $selectAP_amount_unquoted;
- $re_amount = quotemeta($form->{"AP_amount_$i"});
- $selectAP_amount =~
- s/option value=\"${re_amount}\"/option value=\"$form->{"AP_amount_$i"}\" selected/;
- $tax = $taxchart;
- $tax_selected = $form->{"taxchart_$i"};
- $tax =~ s/value=\"$tax_selected\"/value=\"$tax_selected\" selected/;
- $tax =
- qq| | | |;
+
+ my $selected_accno_full;
+ my ($accno_row) = split(/--/, $form->{"AP_amount_$i"});
+ my $item = $charts{$accno_row};
+ $selected_accno_full = "$item->{accno}--$item->{tax_id}";
+
+ my $selected_taxchart = $form->{"taxchart_$i"};
+ my ($selected_accno, $selected_tax_id) = split(/--/, $selected_accno_full);
+ my ($previous_accno, $previous_tax_id) = split(/--/, $form->{"previous_AP_amount_$i"});
+
+ if ($previous_accno &&
+ ($previous_accno eq $selected_accno) &&
+ ($previous_tax_id ne $selected_tax_id)) {
+ my $item = $taxcharts{$selected_tax_id};
+ $selected_taxchart = "$item->{id}--$item->{rate}";
+ }
+
+ $selected_taxchart = $taxchart_init unless ($form->{"taxchart_$i"});
+
+ $selectAP_amount =
+ NTI($cgi->popup_menu('-name' => "AP_amount_$i",
+ '-id' => "AP_amount_$i",
+ '-style' => 'width:400px',
+ '-onChange' => "setTaxkey(this, $i)",
+ '-values' => \@AP_amount_values,
+ '-labels' => \%AP_amount_labels,
+ '-default' => $selected_accno_full))
+ . $cgi->hidden('-name' => "previous_AP_amount_$i",
+ '-default' => $selected_accno_full);
+
+ $tax = qq|| .
+ NTI($cgi->popup_menu('-name' => "taxchart_$i",
+ '-id' => "taxchart_$i",
+ '-style' => 'width:200px',
+ '-values' => \@taxchart_values,
+ '-labels' => \%taxchart_labels,
+ '-default' => $selected_taxchart))
+ . qq| | |;
my $korrektur = $form->{"korrektur_$i"} ? 'checked' : '';
+ my $projectnumber =
+ NTI($cgi->popup_menu('-name' => "project_id_$i",
+ '-values' => \@project_values,
+ '-labels' => \%project_labels,
+ '-default' => $form->{"project_id_$i"} ));
+
print qq|
- |
+ $selectAP_amount |
{"amount_$i"}> |
{"tax_$i"}> |
|
$tax
-
- {"project_id_$i"}>
- |
+ $projectnumber |
|;
$amount = "";
@@ -572,6 +671,11 @@ $jsscript
$form->{invtotal} = $form->format_amount(\%myconfig, $form->{invtotal}, 2);
+ $APselected =
+ NTI($cgi->popup_menu('-name' => "APselected", '-id' => "APselected",
+ '-style' => 'width:400px',
+ '-values' => \@AP_values, '-labels' => \%AP_labels,
+ '-default' => $form->{APselected}));
print qq|
@@ -579,8 +683,7 @@ $jsscript
|
- |
-
+ ${APselected} |
$form->{invtotal} |
{oldinvtotal}>
@@ -609,14 +712,14 @@ $jsscript
- | . $locale->text('Payments') . qq| |
+ | . $locale->text('Payments') . qq| |
|;
if ($form->{currency} eq $form->{defaultcurrency}) {
- @column_index = qw(datepaid source memo paid AP_paid);
+ @column_index = qw(datepaid source memo paid AP_paid paid_project_id);
} else {
- @column_index = qw(datepaid source memo paid exchangerate AP_paid);
+ @column_index = qw(datepaid source memo paid exchangerate AP_paid paid_project_id);
}
$column_data{datepaid} = "" . $locale->text('Date') . " | ";
@@ -625,6 +728,7 @@ $jsscript
$column_data{AP_paid} = "" . $locale->text('Account') . " | ";
$column_data{source} = "" . $locale->text('Source') . " | ";
$column_data{memo} = "" . $locale->text('Memo') . " | ";
+ $column_data{paid_project_id} = "" . $locale->text('Project Number') . " | ";
print "
@@ -634,15 +738,19 @@ $jsscript
";
+ my @triggers = ();
$form->{paidaccounts}++ if ($form->{"paid_$form->{paidaccounts}"});
for $i (1 .. $form->{paidaccounts}) {
print "
";
- $form->{"selectAP_paid_$i"} = $form->{selectAP_paid};
- $form->{"selectAP_paid_$i"} =~
- s/option value=\"$form->{"AP_paid_$i"}\">/option value=\"$form->{"AP_paid_$i"}\" selected>/;
+ $selectAP_paid =
+ NTI($cgi->popup_menu('-name' => "AP_paid_$i",
+ '-id' => "AP_paid_$i",
+ '-values' => \@AP_paid_values,
+ '-labels' => \%AP_paid_labels,
+ '-default' => $form->{"AP_paid_$i"}));
# format amounts
if ($form->{"paid_$i"}) {
@@ -668,27 +776,35 @@ $jsscript
|;
$column_data{"paid_$i"} =
- qq|{"paid_$i"}> | |;
+ qq| | |;
$column_data{"AP_paid_$i"} =
- qq| | |;
+ qq|${selectAP_paid} | |;
$column_data{"exchangerate_$i"} = qq|$exchangerate | |;
$column_data{"datepaid_$i"} =
- qq|{"datepaid_$i"}> | |;
+ qq|
+ | |;
$column_data{"source_$i"} =
qq| | |;
$column_data{"memo_$i"} =
qq| | |;
+ $column_data{"paid_project_id_$i"} =
+ qq||
+ . NTI($cgi->popup_menu('-name' => "paid_project_id_$i",
+ '-values' => \@project_values,
+ '-labels' => \%project_labels,
+ '-default' => $form->{"paid_project_id_$i"} ))
+ . qq| | |;
map { print qq|$column_data{"${_}_$i"}\n| } @column_index;
print "
";
+ push(@triggers, "datepaid_$i", "BL", "trigger_datepaid_$i");
}
- map { $form->{$_} =~ s/\"/"/g } qw(selectAP_paid);
- print qq|
+ print $form->write_trigger(\%myconfig, scalar(@triggers) / 3, @triggers) .
+ qq|
{paidaccounts}>
-
|
@@ -708,49 +824,69 @@ sub form_footer {
print qq|
+
-{path}>
{login}>
{password}>
+|
+. $cgi->hidden('-name' => 'draft_id', '-default' => [$form->{draft_id}])
+. $cgi->hidden('-name' => 'draft_description', '-default' => [$form->{draft_description}])
+. qq|
|;
+ if (!$form->{id} && $form->{draft_id}) {
+ print(NTI($cgi->checkbox('-name' => 'remove_draft', '-id' => 'remove_draft',
+ '-value' => 1, '-checked' => $form->{remove_draft},
+ '-label' => '')) .
+ qq|
|);
+ }
+
$transdate = $form->datetonum($form->{transdate}, \%myconfig);
$closedto = $form->datetonum($form->{closedto}, \%myconfig);
+ print qq||;
+
if ($form->{id}) {
# print qq|
# |;
- if ($form->{radier}) {
- print qq|
+ if ($form->{radier}) {
+ print qq|
|;
- }
+ }
- print qq|
+ print qq|
+
|;
-
- } else {
- if (($transdate > $closedto) && !$form->{id}) {
- print qq|
+ } elsif (($transdate > $closedto) && !$form->{id}) {
+ print qq|
|;
- }
+ . $locale->text('Post') . qq|"> | .
+ NTI($cgi->submit('-name' => 'action', '-value' => $locale->text('Save draft'),
+ '-class' => 'submit'));
}
-
- if ($form->{menubar}) {
- require "$form->{path}/menu.pl";
- &menubar;
+ # button for saving history
+ if($form->{id} ne "") {
+ print qq|
+ {id}
+ . qq|); name=history id=history value=|
+ . $locale->text('history')
+ . qq|>|;
}
-
+ # /button for saving history
print "
@@ -766,28 +902,8 @@ sub update {
my $display = shift;
- # if ($display) {
- # goto TAXCALC;
- # }
-
$form->{invtotal} = 0;
- # $form->{selectAP_amount} = $form->{AP_amount};
- # $form->{selectAP_amount} =~
- # s/value=\"$form->{AP_amountselected}\"/value=\"$form->{AP_amountselected}\" selected/;
-
- $form->{selectAP} = $form->{AP};
- $form->{selectAP} =~
- s/value=\"$form->{APselected}\"/value=\"$form->{APselected}\" selected/;
-
- ($AP_amountaccno, $AP_amounttaxkey) =
- split(/--/, $form->{AP_amountselected});
- $form->{selecttaxchart} = $form->{taxchart};
- $form->{selecttaxchart} =~
- s/value=\"$AP_amounttaxkey--([^\"]*)\"/value=\"$AP_amounttaxkey--$1\" selected/;
-
- $form->{rate} = $1;
-
map { $form->{$_} = $form->parse_amount(\%myconfig, $form->{$_}) }
qw(exchangerate creditlimit creditremaining);
@@ -836,7 +952,6 @@ sub update {
&check_name(vendor);
$form->{AP} = $save_AP;
- &check_project;
$form->{rowcount} = $count + 1;
$form->{invtotal} =
@@ -872,6 +987,38 @@ sub update {
$lxdebug->leave_sub();
}
+
+sub post_payment {
+ $lxdebug->enter_sub();
+ for $i (1 .. $form->{paidaccounts}) {
+ if ($form->{"paid_$i"}) {
+ $datepaid = $form->datetonum($form->{"datepaid_$i"}, \%myconfig);
+
+ $form->isblank("datepaid_$i", $locale->text('Payment date missing!'));
+
+ $form->error($locale->text('Cannot post payment for a closed period!'))
+ if ($datepaid <= $closedto);
+
+ if ($form->{currency} ne $form->{defaultcurrency}) {
+ $form->{"exchangerate_$i"} = $form->{exchangerate}
+ if ($invdate == $datepaid);
+ $form->isblank("exchangerate_$i",
+ $locale->text('Exchangerate for payment missing!'));
+ }
+ }
+ }
+
+ ($form->{AP}) = split /--/, $form->{AP};
+ ($form->{AP_paid}) = split /--/, $form->{AP_paid};
+ $form->redirect($locale->text(' Payment posted!'))
+ if (AP->post_payment(\%myconfig, \%$form));
+ $form->error($locale->text('Cannot post payment!'));
+
+
+ $lxdebug->leave_sub();
+}
+
+
sub post {
$lxdebug->enter_sub();
@@ -924,8 +1071,17 @@ sub post {
$form->{id} = 0 if $form->{postasnew};
- $form->redirect($locale->text('Transaction posted!'))
- if (AP->post_transaction(\%myconfig, \%$form));
+ if (AP->post_transaction(\%myconfig, \%$form)) {
+ # saving the history
+ if(!exists $form->{addition} && $form->{id} ne "") {
+ $form->{snumbers} = qq|invnumber_| . $form->{invnumber};
+ $form->{addition} = "POSTED";
+ $form->save_history($form->dbconnect(\%myconfig));
+ }
+ # /saving the history
+ remove_draft() if $form->{remove_draft};
+ $form->redirect($locale->text('Transaction posted!'));
+ }
$form->error($locale->text('Cannot post transaction!'));
$lxdebug->leave_sub();
@@ -935,6 +1091,13 @@ sub post_as_new {
$lxdebug->enter_sub();
$form->{postasnew} = 1;
+ # saving the history
+ if(!exists $form->{addition} && $form->{id} ne "") {
+ $form->{snumbers} = qq|invnumber_| . $form->{invnumber};
+ $form->{addition} = "POSTED AS NEW";
+ $form->save_history($form->dbconnect(\%myconfig));
+ }
+ # /saving the history
&post;
$lxdebug->leave_sub();
@@ -992,9 +1155,16 @@ sub delete {
sub yes {
$lxdebug->enter_sub();
-
- $form->redirect($locale->text('Transaction deleted!'))
- if (AP->delete_transaction(\%myconfig, \%$form, $spool));
+ if (AP->delete_transaction(\%myconfig, \%$form, $spool)) {
+ # saving the history
+ if(!exists $form->{addition}) {
+ $form->{snumbers} = qq|invnumber_| . $form->{invnumber};
+ $form->{addition} = "DELETED";
+ $form->save_history($form->dbconnect(\%myconfig));
+ }
+ # /saving the history
+ $form->redirect($locale->text('Transaction deleted!'));
+ }
$form->error($locale->text('Cannot delete transaction!'));
$lxdebug->leave_sub();
@@ -1040,12 +1210,12 @@ sub search {
# with JavaScript Calendar
$button1 = qq|
-
+ |
text('button') . qq|> |
|;
$button2 = qq|
-
+ |
text('button') . qq|> |
|;
@@ -1058,15 +1228,29 @@ sub search {
# without JavaScript Calendar
$button1 = qq|
- | |;
+ | |;
$button2 = qq|
- | |;
+ | |;
}
- $form->header;
+ $form->get_lists("projects" => { "key" => "ALL_PROJECTS",
+ "all" => 1 });
+ my %labels = ();
+ my @values = ("");
+ foreach my $item (@{ $form->{"ALL_PROJECTS"} }) {
+ push(@values, $item->{"id"});
+ $labels{$item->{"id"}} = $item->{"projectnumber"};
+ }
+ my $projectnumber =
+ NTI($cgi->popup_menu('-name' => 'project_id', '-values' => \@values,
+ '-labels' => \%labels));
+ $form->{javascript} .= qq||;
+ $form->header;
+ $onload = qq|;setupDateFormat('|. $myconfig{dateformat} .qq|', '|. $locale->text("Falsches Datumsformat!") .qq|')|;
+ $onload .= qq|;setupPoints('|. $myconfig{numberformat} .qq|', '|. $locale->text("wrongformat") .qq|')|;
print qq|
-
+
+
+ | . $locale->text("Project Number") . qq| |
+ $projectnumber |
+
| . $locale->text('From') . qq| |
$button1
@@ -1159,6 +1347,8 @@ sub search {
|
| . $locale->text('Subtotal') . qq| |
+ |
+ | . $locale->text('Project Number') . qq| |
@@ -1175,7 +1365,6 @@ $jsscript