X-Git-Url: http://wagnertech.de/git?a=blobdiff_plain;ds=inline;f=bin%2Fmozilla%2Fap.pl;h=54a9c94b489a246d3f68094515d189ec30d670fb;hb=15f549fdb43fba2d99817c659533dfa02638bf27;hp=34b285de3445e2de29b9dcbce497b1284be8e586;hpb=a4b22a8f008d6431597fa80de26bcb0fa10e8d7b;p=kivitendo-erp.git
diff --git a/bin/mozilla/ap.pl b/bin/mozilla/ap.pl
index 34b285de3..54a9c94b4 100644
--- a/bin/mozilla/ap.pl
+++ b/bin/mozilla/ap.pl
@@ -37,6 +37,7 @@ use SL::PE;
require "$form->{path}/arap.pl";
require "bin/mozilla/common.pl";
+require "bin/mozilla/drafts.pl";
1;
@@ -73,6 +74,8 @@ require "bin/mozilla/common.pl";
sub add {
$lxdebug->enter_sub();
+ return $lxdebug->leave_sub() if (load_draft_maybe());
+
$form->{title} = "Add";
$form->{callback} =
@@ -88,6 +91,9 @@ sub add {
sub edit {
$lxdebug->enter_sub();
+ # show history button
+ $form->{javascript} = qq||;
+ #/show hhistory button
$form->{title} = "Edit";
@@ -193,6 +199,7 @@ sub create_links {
$form->{"forex_$j"} = $form->{"exchangerate_$i"} =
$form->{acc_trans}{$key}->[$i - 1]->{exchangerate};
$form->{"AP_paid_$j"} = "$form->{acc_trans}{$key}->[$i-1]->{accno}";
+ $form->{"paid_project_id_$j"} = $form->{acc_trans}{$key}->[$i - 1]->{project_id};
$form->{paidaccounts}++;
} else {
@@ -397,6 +404,21 @@ sub form_header {
? qq||
: qq||;
+ my @old_project_ids = ();
+ map({ push(@old_project_ids, $form->{"project_id_$_"})
+ if ($form->{"project_id_$_"}); } (1..$form->{"rowcount"}));
+
+ $form->get_lists("projects" => { "key" => "ALL_PROJECTS",
+ "all" => 0,
+ "old_id" => \@old_project_ids });
+
+ my %project_labels = ();
+ my @project_values = ("");
+ foreach my $item (@{ $form->{"ALL_PROJECTS"} }) {
+ push(@project_values, $item->{"id"});
+ $project_labels{$item->{"id"}} = $item->{"projectnumber"};
+ }
+
# use JavaScript Calendar or not
$form->{jsscript} = $jscalendar;
$jsscript = "";
@@ -440,6 +462,8 @@ sub form_header {
{locked}>
+| . ($form->{saved_message} ? qq|
$form->{saved_message}
| : "") . qq|
+
$form->{title} |
@@ -558,6 +582,12 @@ $jsscript
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|
|
@@ -565,9 +595,7 @@ $jsscript
{"tax_$i"}> |
|
$tax
-
- {"project_id_$i"}>
- |
+ $projectnumber |
|;
$amount = "";
@@ -618,14 +646,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') . " | ";
@@ -634,6 +662,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 "
@@ -689,6 +718,13 @@ $jsscript
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;
@@ -721,10 +757,15 @@ 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|
|;
@@ -732,36 +773,45 @@ sub form_footer {
$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|
-|;
- 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'));
}
-
+ # 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 "
@@ -843,7 +893,6 @@ sub update {
&check_name(vendor);
$form->{AP} = $save_AP;
- &check_project;
$form->{rowcount} = $count + 1;
$form->{invtotal} =
@@ -963,8 +1012,16 @@ 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->{addition} = "POSTED";
+ $form->save_history($form->dbconnect(\%myconfig));
+ }
+ # /saving the history
+ remove_draft();
+ $form->redirect($locale->text('Transaction posted!'));
+ }
$form->error($locale->text('Cannot post transaction!'));
$lxdebug->leave_sub();
@@ -974,6 +1031,12 @@ sub post_as_new {
$lxdebug->enter_sub();
$form->{postasnew} = 1;
+ # saving the history
+ if(!exists $form->{addition} && $form->{id} ne "") {
+ $form->{addition} = "POSTED AS NEW";
+ $form->save_history($form->dbconnect(\%myconfig));
+ }
+ # /saving the history
&post;
$lxdebug->leave_sub();
@@ -1031,9 +1094,15 @@ 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->{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();
|