X-Git-Url: http://wagnertech.de/git?a=blobdiff_plain;f=bin%2Fmozilla%2Fap.pl;h=54a9c94b489a246d3f68094515d189ec30d670fb;hb=15f549fdb43fba2d99817c659533dfa02638bf27;hp=a18c638a74e6d25a6d2346f7378369d724314fbe;hpb=2387a1fccb259789836aa1a9da44528be4d63bec;p=kivitendo-erp.git diff --git a/bin/mozilla/ap.pl b/bin/mozilla/ap.pl index a18c638a7..54a9c94b4 100644 --- a/bin/mozilla/ap.pl +++ b/bin/mozilla/ap.pl @@ -36,6 +36,8 @@ use SL::IR; use SL::PE; require "$form->{path}/arap.pl"; +require "bin/mozilla/common.pl"; +require "bin/mozilla/drafts.pl"; 1; @@ -72,6 +74,8 @@ require "$form->{path}/arap.pl"; sub add { $lxdebug->enter_sub(); + return $lxdebug->leave_sub() if (load_draft_maybe()); + $form->{title} = "Add"; $form->{callback} = @@ -87,6 +91,9 @@ sub add { sub edit { $lxdebug->enter_sub(); + # show history button + $form->{javascript} = qq||; + #/show hhistory button $form->{title} = "Edit"; @@ -192,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 { @@ -279,6 +287,8 @@ sub create_links { ($form->datetonum($form->{transdate}, \%myconfig) <= $form->datetonum($form->{closedto}, \%myconfig)); + $form->{"APselected"} = $form->{"AP_1"}; + $lxdebug->leave_sub(); } @@ -321,6 +331,11 @@ sub form_header { } $readonly = ($form->{id}) ? "readonly" : ""; + my $APselected_quoted = quotemeta($form->{"APselected"}); + $form->{selectAP} = $form->{AP}; + $form->{selectAP} =~ + s/value=\"${APselected_quoted}\"/value=\"$form->{APselected}\" selected/; + $form->{radier} = ($form->current_date(\%myconfig) eq $form->{gldate}) ? 1 : 0; $readonly = ($form->{radier}) ? "" : $readonly; @@ -389,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 = ""; @@ -432,6 +462,8 @@ sub form_header { {locked}> +| . ($form->{saved_message} ? qq|

$form->{saved_message}

| : "") . qq| + @@ -550,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| @@ -557,9 +595,7 @@ $jsscript $tax - + |; $amount = ""; @@ -610,14 +646,14 @@ $jsscript @@ -1262,10 +1388,14 @@ sub ap_transactions { $option .= "\n
" if ($option); $option .= $locale->text('Closed'); } + if ($form->{globalproject_id}) { + $callback .= "&globalproject_id=" . E($form->{globalproject_id}); + $href .= "&globalproject_id=" . E($form->{globalproject_id}); + } - @columns = $form->sort_columns( - qw(transdate id invnumber ordnumber name netamount tax amount paid datepaid due duedate notes employee) - ); + @columns = + qw(transdate id invnumber ordnumber name netamount tax amount paid datepaid + due duedate notes employee globalprojectnumber); foreach $item (@columns) { if ($form->{"l_$item"} eq "Y") { @@ -1325,6 +1455,8 @@ sub ap_transactions { $column_header{employee} = ""; + $column_header{globalprojectnumber} = + qq||; $form->{title} = $locale->text('AP Transactions'); @@ -1415,6 +1547,8 @@ sub ap_transactions { $ap->{notes} =~ s/\r\n/
/g; $column_data{notes} = ""; $column_data{employee} = ""; + $column_data{globalprojectnumber} = + ""; $i++; $i %= 2; @@ -1483,14 +1617,8 @@ sub ap_transactions { . $locale->text('AP Transaction') . qq|"> |; - - if ($form->{menubar}) { - require "$form->{path}/menu.pl"; - &menubar; - } + . $locale->text('Vendor Invoice') . qq|"> - print qq|
$form->{title}
{"tax_$i"}> - {"project_id_$i"}> - $projectnumber
- + |; 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} = ""; @@ -626,6 +662,7 @@ $jsscript $column_data{AP_paid} = ""; $column_data{source} = ""; $column_data{memo} = ""; + $column_data{paid_project_id} = ""; print " @@ -635,6 +672,7 @@ $jsscript "; + my @triggers = (); $form->{paidaccounts}++ if ($form->{"paid_$form->{paidaccounts}"}); for $i (1 .. $form->{paidaccounts}) { print " @@ -674,20 +712,30 @@ $jsscript qq||; $column_data{"exchangerate_$i"} = qq||; $column_data{"datepaid_$i"} = - qq||; + qq||; $column_data{"source_$i"} = qq||; $column_data{"memo_$i"} = qq||; + $column_data{"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}> @@ -709,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|
|; @@ -720,38 +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| + |; - - } 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 " @@ -777,10 +837,6 @@ sub update { # $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}; @@ -837,7 +893,6 @@ sub update { &check_name(vendor); $form->{AP} = $save_AP; - &check_project; $form->{rowcount} = $count + 1; $form->{invtotal} = @@ -873,6 +928,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(); @@ -925,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(); @@ -936,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(); @@ -993,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(); @@ -1064,6 +1171,19 @@ sub search { |; } + $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->header; print qq| @@ -1096,6 +1216,10 @@ sub search { + + + + $button1 @@ -1160,6 +1284,8 @@ sub search { + +
| . $locale->text('Payments') . qq|| . $locale->text('Payments') . qq|
" . $locale->text('Date') . "" . $locale->text('Account') . "" . $locale->text('Source') . "" . $locale->text('Memo') . "" . $locale->text('Project Number') . "
$exchangerate{"datepaid_$i"}>{"datepaid_$i"}> + | + . NTI($cgi->popup_menu('-name' => "paid_project_id_$i", + '-values' => \@project_values, + '-labels' => \%project_labels, + '-default' => $form->{"paid_project_id_$i"} )) + . qq|
| . $locale->text('Notes') . qq|
| . $locale->text("Project Number") . qq|$projectnumber
| . $locale->text('From') . qq|
| . $locale->text('Subtotal') . qq|| . $locale->text('Project Number') . qq|
" . $locale->text('Employee') . "| . $locale->text('Project Number') . qq|$ap->{notes} $ap->{employee} " . H($ap->{globalprojectnumber}) . "