use SL::FU;
use SL::IS;
use SL::PE;
+use SL::DB::Default;
use SL::ReportGenerator;
require "bin/mozilla/arap.pl";
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();
$form->{javascript} .= qq|<script type="text/javascript" src="js/common.js"></script>|;
$form->{title} = "Edit";
- &create_links;
+ create_links();
&display_form;
$main::lxdebug->leave_sub();
$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);
my ($title, $readonly, $exchangerate, $rows);
my ($notes, $department, $customer, $employee, $amount, $project);
- my ($onload);
my ($ARselected);
#/show history button js
$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
$taxcharts{$item->{id}} = $item;
}
- $form->{fokus} = "arledger.customer";
+ $::request->{layout}->focus("#customer");
my $follow_up_vc = $form->{customer};
$follow_up_vc =~ s/--.*?//;
qq|<script type="text/javascript" src="js/show_vc_details.js"></script>| .
qq|<script type="text/javascript" src="js/follow_up.js"></script>|;
- $onload = qq|focus()|;
- $onload .= qq|;setupPoints('|. $myconfig{numberformat} .qq|', '|. $locale->text("wrongformat") .qq|')|;
-
# $amount = $locale->text('Amount');
# $project = $locale->text('Project');
for my $i (1 .. $form->{rowcount}) {
my $transaction = {
amount => $form->{"amount_$i"},
- tax => $form->{"tax$i"},
- project_id => $form->{"project_id_$i"},
+ tax => $form->{"tax_$i"},
+ project_id => ($i==$form->{rowcount}) ? $form->{globalproject_id} : $form->{"project_id_$i"},
};
my $selected_accno_full;
. $cgi->hidden('-name' => "previous_AR_amount_$i",
'-default' => $selected_accno_full);
- $transaction->{tax} =
+ $transaction->{taxchart} =
NTI($cgi->popup_menu('-name' => "taxchart_$i",
'-id' => "taxchart_$i",
'-style' => 'width:200px',
$payment->{changeable} =
- $::lx_office_conf{features}->{payments_changeable} == 0 ? !$payment->{acc_trans_id} # never
- : $::lx_office_conf{features}->{payments_changeable} == 2 ? $payment->{gldate} eq '' || $payment->{gldate} eq $now
+ SL::DB::Default->get->payments_changeable == 0 ? !$payment->{acc_trans_id} # never
+ : SL::DB::Default->get->payments_changeable == 2 ? $payment->{gldate} eq '' || $payment->{gldate} eq $now
: 1;
push @payments, $payment;
project_labels => \%project_labels,
rows => $rows,
ARselected => $ARselected,
- onload => $onload,
title_str => $title,
follow_up_trans_info => $follow_up_trans_info,
});
my $locale = $main::locale;
my $cgi = $::request->{cgi};
- my ($transdate, $closedto);
-
- my $follow_ups_block;
- if ($form->{id}) {
+ if ( $form->{id} ) {
my $follow_ups = FU->follow_ups('trans_id' => $form->{id});
-
- if (@{ $follow_ups} ) {
- my $num_due = sum map { $_->{due} * 1 } @{ $follow_ups };
- $follow_ups_block = qq|<p>| . $locale->text("There are #1 unfinished follow-ups of which #2 are due.", scalar @{ $follow_ups }, $num_due) . qq|</p>|;
+ if ( @{ $follow_ups} ) {
+ $form->{follow_up_length} = scalar(@{$follow_ups});
+ $form->{follow_up_due_length} = sum(map({ $_->{due} * 1 } @{ $follow_ups }));
}
}
- print qq|
-
-$follow_ups_block
-
-<input name=gldate type=hidden value="| . Q($form->{gldate}) . qq|">
-
-<input name=callback type=hidden value="$form->{callback}">
-|
-. $cgi->hidden('-name' => 'draft_id', '-default' => [$form->{draft_id}])
-. $cgi->hidden('-name' => 'draft_description', '-default' => [$form->{draft_description}])
-. qq|
-
-<br>
-|;
-
- if (!$form->{id} && $form->{draft_id}) {
- print(NTI($cgi->checkbox('-name' => 'remove_draft', '-id' => 'remove_draft',
- '-value' => 1, '-checked' => $form->{remove_draft},
- '-label' => '')) .
- qq| <label for="remove_draft">| .
- $locale->text("Remove draft when posting") .
- qq|</label><br>|);
- }
-
- $transdate = $form->datetonum($form->{transdate}, \%myconfig);
- $closedto = $form->datetonum($form->{closedto}, \%myconfig);
+ my $transdate = $form->datetonum($form->{transdate}, \%myconfig);
+ my $closedto = $form->datetonum($form->{closedto}, \%myconfig);
- print qq|<input class="submit" type="submit" name="action" id="update_button" value="| . $locale->text('Update') . qq|">\n|;
+ $form->{is_closed} = $transdate <= $closedto;
# ToDO: - insert a global check for stornos, so that a storno is only possible a limited time after saving it
- print qq| <input class=submit type=submit name=action value="| . $locale->text('Storno') . qq|"> |
- if ($form->{id} && !IS->has_storno(\%myconfig, $form, 'ar') && !IS->is_storno(\%myconfig, $form, 'ar') && (($form->{totalpaid} == 0) || ($form->{totalpaid} eq "")));
-
- if ($form->{id}) {
- if ($form->{radier}) {
- print qq|
- <input class=submit type=submit name=action value="| . $locale->text('Post') . qq|">
- <input class=submit type=submit name=action value="| . $locale->text('Delete') . qq|"> |;
- }
- if ($transdate > $closedto) {
- print qq|
- <input class=submit type=submit name=action value="| . $locale->text('Use As Template') . qq|"> |;
- }
- print qq|
- <input class=submit type=submit name=action value="| . $locale->text('Post Payment') . qq|">
- <input type="button" class="submit" onclick="follow_up_window()" value="|
- . $locale->text('Follow-Up')
- . qq|"> |;
-
- } else {
- if ($transdate > $closedto) {
- print qq| <input class=submit type=submit name=action value="| . $locale->text('Post') . qq|"> | .
- NTI($cgi->submit('-name' => 'action', '-value' => $locale->text('Save draft'), '-class' => 'submit'));
- }
- }
+ $form->{show_storno_button} =
+ $form->{id} &&
+ !IS->has_storno(\%myconfig, $form, 'ar') &&
+ !IS->is_storno(\%myconfig, $form, 'ar') &&
+ ($form->{totalpaid} == 0 || $form->{totalpaid} eq "");
- if ($form->{menubar}) {
- require "bin/mozilla/menu.pl";
- &menubar;
- }
- # button for saving history
- if($form->{id} ne "") {
- print qq| <input type=button class=submit onclick=set_history_window($form->{id}); name=history id=history value=| . $locale->text('history') . qq|> |;
- }
- # /button for saving history
- # mark_as_paid button
- if($form->{id} ne "") {
- print qq|<input type="submit" class="submit" name="action" value="|
- . $locale->text('mark as paid') . qq|">|;
- }
- # /mark_as_paid button
-
- print "
-</form>
+ $form->{show_mark_as_paid_button} = $form->{id} && $::instance_conf->get_ar_show_mark_as_paid();
-</body>
-</html>
-";
+ print $::form->parse_html_template('ar/form_footer');
$main::lxdebug->leave_sub();
}
$form->{invdate} = $form->{transdate};
- my %saved_variables = map +( $_ => $form->{$_} ), qw(AR AR_amount_1 taxchart_1 customer_id);
+ my %saved_variables = map +( $_ => $form->{$_} ), qw(AR AR_amount_1 taxchart_1 customer_id notes);
&check_name("customer");
- # check_name loads customer notes into notes, but ar only knows intnotes, so copy them
- $form->{notes} = $form->{intnotes} if $saved_variables{customer_id} != $form->{customer_id};
-
$form->{AR} = $saved_variables{AR};
if ($saved_variables{AR_amount_1} =~ m/.--./) {
map { $form->{$_} = $saved_variables{$_} } qw(AR_amount_1 taxchart_1);
$main::lxdebug->leave_sub();
}
-sub use_as_template {
+sub use_as_new {
$main::lxdebug->enter_sub();
$main::auth->assert('general_ledger');
delete $form->{header};
print qq|
-<body>
-
<form method=post action=$form->{script}>
|;
<input name=action class=submit type=submit value="|
. $locale->text('Yes') . qq|">
</form>
-
-</body>
-</html>
|;
$main::lxdebug->leave_sub();
my $cgi = $::request->{cgi};
my ($customer, $department);
- my ($jsscript, $button1, $button2, $onload);
+ my ($jsscript, $button1, $button2);
# setup customer selection
$form->all_vc(\%myconfig, "customer", "AR");